Skip to main content

Python library for scraping data sources and creating readable deltas

Project description



PyPI Travis CI Documentation Status License

Python library for scraping data sources and creating readable deltas.

For background, see Scraping hurricane Irma.


This library allows you to define scrapers, which are objects that know how to retrieve information from a source (usually a web API, but scrapers can be written to operate against HTML or other formats) and persist that data somewhere as JSON.

When a scraper fetches fresh information it has the ability to compare that data to the old data and use the difference to create a human-readable message.

These capabilities can be combined with a git repository to create a commit log, with human-readable commit messages that accompany a machine-readable diff againts the generated JSON.

See disaster-scrapers and disaster-data for some examples of this pattern in action.

Basic usage

You can define new scrapers by subclassing DeltaScraper. Here's an example which scrapes a list of FEMA shelters.

class FemaShelters(DeltaScraper):
    url = ""
    owner = "simonw"
    repo = "disaster-data"
    filepath = "fema/shelters.json"

    record_key = "SHELTER_ID"
    noun = "shelter"

    def fetch_data(self):
        data = requests.get(self.url, timeout=10).json()
        return [feature["properties"] for feature in data["features"]]

    def display_record(self, record):
        display = []
            "  {SHELTER_NAME} in {CITY}, {STATE} ({SHELTER_STATUS})".format(**record)
        display.append("    population = {TOTAL_POPULATION}".format(**record))
        return "\n".join(display)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for delta-scraper, version 0.1a1
Filename, size File type Python version Upload date Hashes
Filename, size delta_scraper-0.1a1-py3-none-any.whl (9.2 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page