Giter VIP home page Giter VIP logo

api's Introduction

A website and API for getting information on students at Yale College.

Setup

To develop changes to the application, you'll need to run it locally for testing.

This guide assumes, as prerequisites, that you have:

  • A MacOS or Linux-based OS (if you use Windows, you can still follow along, but some commands may be different)
  • Python 3 (included by default with many computers, or available here)
  • Access to, and basic understanding of, the terminal on your computer

Once all prerequisites are installed, clone this repository to your machine from your terminal:

git clone https://github.com/Yalies/api

Then, enter the directory:

cd api

Install dependencies:

pip3 install -r requirements.txt
pip3 install -r requirements-test.txt

If pip3 is not recognized, you'll need to install Python 3 on your system.

Running

To locally launch the application:

FLASK_APP=app.py FLASK_ENV=development flask run

The app will subsequently be available at localhost:5000.

When running locally, the app will use a non-hosted SQLite database, meaning that all database contents will be stored in app.db. If you wish to run SQL queries on this database, simply install sqlite (best obtained through Homebrew or other package manager), and run:

sqlite3 app.db

Scraper

One major component of the app is our scraper, which crawls through Yale's websites and extracts the information that Yalies provides. This information is then cleaned up and inserted into the database.

To run the scraper process (not necessary if you just want to view the website):

celery -A app.celery worker --loglevel=INFO

In order to actually execute the scraper, visit localhost:5000/scraper and fill in the fields. To retrieve the tokens you need, you'll want to use the developer tools ("inspect element") for your browser, specifically the Network tab, to view the headers on requests made to the Face Book and Directory.

Face Book

Open the Yale Face Book and log in if necessary. In the developer tools, choose any request and grab the Cookie property in its entirety.

Directory

Open the Yale Directory and log in if necessary. Perform a search, and in the developer tools, select the query to the api endpoint. You'll notice the Cookie is too long to be displayed without elipses, so right click and copy it elsewhere then extract only the _people_search_session value. Then, grab the X-CSRF-Token header value.

License

MIT

Author

Erik Boesen

api's People

Contributors

erikboesen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.