Code Monkey home page Code Monkey logo

foursquare-venue-scraper's Introduction

UPDATE MARCH 2019: This repo is depreciated due to API changes by Foursquare to stop scraping of this particular metadata. This repository will remain up for posterity.

foursquare-venue-scraper

A Foursquare data scraper that gathers all venues within a specified geographic area. The data retrieved can then be used for statistical analysis and fun data visualizations.

Overview

The script queries the official Foursquare API (with a user-provided client_id and client_secret from a Foursquare application) to search for venues, and then query additional metadata for each unique venue.

The specified area is defined by a geographic bounding box (by latitude and longitude). Since the API can only return up to 50 venues per search, the bounding box is broken into sub-bounding boxes as a form of grid search (by default, the grid_size is 100, so 100x100=10000 searches total).

The output file is a CSV with the following fields:

  • id — The Foursquare ID for the venue.
  • name — The name of the venue.
  • categories — The list of categories of the venue.
  • lat — Latitude
  • long — Longitude
  • num_checkins — Number of Foursquare Checkins
  • num_likes — Number of Foursquare Likes
  • price — Price Tier between 1-4 (i.e. $-$$$$)
  • rating — Rating for the venue.
  • num_ratings — Number of ratings for the venue.
  • url_venue — URL of the venue.
  • url_foursquare — URL for the Foursquare venue.

A demo CSV of the Top 100 San Francisco venues (by number of checkins) is available in foursquare_sf_sample.csv.

Usage

Set the parameters in config.yaml as appropriate, then run foursquare_venues.py.

The Foursquare API has a daily rate limit of 1,000 requests/day for free accounts, but with verification, the rate limit upgrades to 100,000/day. You can test the script with a small bounding box/low grid size to see if it fits your needs before upgrading.

Both of the API endpoints used in this script have a rate limit of 5,000 requests/hour. Once the script hits that limit, it'll sleep for an hour. Plan scraping accordingly.

Foursquare Terms of Use

This script follows the specifications of the Foursquare API, and does not circumvent the API and its rate limits. If you're using the data for projects other than data analysis, make sure to follow the Foursquare Terms of Use.

Maintainer

Max Woolf (@minimaxir)

Max's open-source projects are supported by his Patreon. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.

License

MIT

foursquare-venue-scraper's People

Contributors

minimaxir 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.