Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query database #36

Open
froriz5 opened this issue Mar 31, 2015 · 2 comments
Open

Query database #36

froriz5 opened this issue Mar 31, 2015 · 2 comments

Comments

@froriz5
Copy link

froriz5 commented Mar 31, 2015

Is there a way to query the database through HTTP Request? I want to get the GPA info of professors (given a professor name) for a side project I'm working on.

@chrisforrence
Copy link
Contributor

We don't currently support an API for this, but I remember it had been discussed in the past.

As a workaround, you can call the prof page with an ID of the professor's name (last name + first name, uppercase):

http://critique.gatech.edu/prof.php?id=MORLEYTHOMAS

@cobookman
Copy link
Collaborator

@froriz5, we nvr built an api. I no longer have access to the database. However you could easily web-scrape.

E.g:

function parseCourseHTML(html) {
    var data = [];
    var div = document.createElement('div');
    div.innerHTML = html;
    var rows  = div.querySelectorAll('table:nth-child(2) tbody tr');

    for(var r = 0, rl= rows.length; r < rl; ++r) {
        var cells = rows[r].children;
        data.push({
            professor: cells[0].textContent,
            size: cells[1].textContent,
            gpa: cells[2].textContent,
            a: cells[3].textContent,
            b: cells[4].textContent,
            c: cells[5].textContent,
            d: cells[6].textContent,
            f: cells[7].textContent,
            w: cells[8].textContent,
        });
    }
    return data;
}

function parseProfHTML(html) {
    var data = [];
    var div = document.createElement('div');
    div.innerHTML = html;
    var rows  = div.querySelectorAll('table:nth-child(2) tbody tr');

    for(var r = 0, rl= rows.length; r < rl; ++r) {
        var cells = rows[r].children;
        data.push({
            course: cells[0].textContent,
            section: cells[1].textContent,
            year: cells[2].textContent,
            size: cells[3].textContent,
            gpa: cells[4].textContent,
            a: cells[5].textContent,
            b: cells[6].textContent,
            c: cells[7].textContent,
            d: cells[8].textContent,
            f: cells[9].textContent,
            w: cells[10].textContent,
        });
    }
    return data;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants