Giter Site home page Giter Site logo

culpa-cache-scraper's Introduction

culpa cache Scraper (Python)

Created by: Richard Shin

CULPA Cache Flow

This project exists to preserve the thousands of reviews that was hosted on CULPA, the unofficial professor and course review site for Columbia University. During the summer of 2021, the site started timing out during peak loads.

This project is broken up into three parts: the Scraper, the API, and the React App.

This portion of the project contains the scraper which was used to scrape CULPA. A tar.gz of the scraped data can be found with the culpa-cache-api repository so you do not have to scrape again.

Getting Started

main.py scrapes CULPA (or Wayback Machine archives) for all pertinent information: professor name, professor ID (as assigned by CULPA), course name of the review, date of the review, review content.

Since professor ID's are not 100% incremental (well, maybe they were, but some are missing/deleted/not cached), the script begins scraping from professor ID 1.

When a successful scrape occurs, a .json file is saved in the data folder with the following naming convention: prof-{id}.json. So, reviews from http://www.culpa.info/professors/1 is saved as prof-1.json.

If the script is unsuccessful in scraping from that ID it'll increment by one and try again.

There are two measures in place to prevent rate limitation:

  1. Quit scraping if there are too many consecutive failed scrapes,
  2. Five second delay in execution of the next scrape (comes out to around ~560 actions per hour).

export.py extracts just the Professor Name and ID from all the .json files in data and compiles it into one file: all_professors.json. This file is later used in the API server.


prof-{id}.json Structure Example

{
    "prof_info": [
        {
            "prof_name": "Ted Mosby",
            "prof_id": 9992,
            "total_reviews": 3
        }
    ],
    "reviews": [
        {
            "course_name": "Architecture 101",
            "review_date": "September 26, 2012",
            "review_content": "Review omitted for readMe.."
        },
        {
            "course_name": "Architecture 101",
            "review_date": "March 10, 2012",
            "review_content": "Review omitted for readMe.."
        },
        {
            "course_name": "Architecture 101",
            "review_date": "February 06, 2012",
            "review_content": "Review omitted for readMe.."
        }
    ]
}

all_professors.json Structure Example

[
  {
    "prof_id": 1,
    "prof_name": "Professor A"
  },
  {
    "prof_id": 2,
    "prof_name": "Professor B"
  },
  {
    "prof_id": 3,
    "prof_name": "Professor C"
  }
]

Required Packages:

You will need to install these packages to get started:

  • pip install requests
  • pip install beautifulsoup4

License

GNU General Public License v3.0

culpa-cache-scraper's People

Watchers

Richard Shin 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.