Giter Site home page Giter Site logo

simonamnv / salaryscrapy Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 1.57 MB

Scrape salaries from Glassdoor, store them in AWS DynamoDB and visual analysis with plotly's Dash

Python 47.81% Procfile 0.06% CSS 50.29% Shell 1.84%
scrapy dynamodb aws heroku salary glassdoor flask scheduler analysis plotly-dash

salaryscrapy's Introduction

Salary Scrapy

This project crawls through Glassdoor and analyzes the salaries per profession and country. The profession is simply declared in the glassdoor_spider.py in an array and the countries are located in utils/country_codes.json. More can be added in both

Crawler

The first part is the crawler. The salaryscraper crawls through specific urls to download the data as seen below:

{
     'country_currency': 'EUR',
     'job_median_payment': '1298',
     'job_percentile10_payment': '869',
     'job_percentile90_payment': '2434',
     'job_title': 'Data Scientist',
     'location': 'Athens, Attica',
     'sample_size': '56'
 }

DynamoDB

This project uses a connection to AWS DynamoDB to store the data in.

  1. Create a new table called "glassdoor" in DynamoDB and create & set partition key to "timestamp"
  2. Go in IAM and create a new User group and under attach permissions policies use only "AmazonDynamoDBFullAccess" also create a user and add him to that group
  3. The above steps will also give you the Access key ID & Secret key access that is needed in order to host this in Heroku add those in environment variables in Heroku and also add in your glassdoor username & password to authenticate the session
  4. The pipeline that stores the data in herokuDB along with the connection initialization is in pipelines.py

Scrapy & Heroku & Flask

  • The glassdoor_spider scrapes the data by creating the URLs based on the information in the static_files
  • Scraping in Heroku is not allowed so proxies should be used instead (salaryscrape/settings.py) and that makes the process slower to make this faster, hit an API with valid proxies instead of a static list
  • The pipelines.py store each parsed item into the dynamodb table

Scheduler

  • When we post a request at /scheduled_crawl, the spider is triggered and then the scheduler takes over to keep triggering it
  • The crawling is scheduled once every 1 month to get data

Core Scrape Architecture

Screenshot 2022-05-15 at 20 34 54

Visualization

Run app.py locally

How to run

  • To run locally simply change SPIDER_MODULES & NEWSPIDER_MODULE & ITEM_PIPELINES in settings.py to salaryscrape.spiders and the same for default in scrapy.cfg. Then run scrapy crawl glassdoor_spider while in the scrapy dir
  • To run in heroku, simply deploy it and run once the /crawl endpoint. Make sure to have all env variables as described above
  • More jobs/countries can be added in salaryscrape/utils/country_codes.json

TODO:

  1. Unit tests
  2. Add circleci for 1) linting 3) unit tests
  3. [future perf] Use .query instead of .scan in the first 2 cases -> https://stackoverflow.com/questions/65282731/dynamodb-select-specific-attributes-using-boto3

salaryscrapy's People

Contributors

simonamnv avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.