Skip to main content

An experimental library for scraping websites using GPT.

Project description

scrapeghost

scrapeghost logo

scrapeghost is an experimental library for scraping websites using OpenAI's GPT.

Source: https://github.com/jamesturk/scrapeghost

Documentation: https://jamesturk.github.io/scrapeghost/

Issues: https://github.com/jamesturk/scrapeghost/issues

PyPI badge Test badge

Use at your own risk. This library makes considerably expensive calls ($0.36 for a GPT-4 call on a moderately sized page.) Cost estimates are based on the OpenAI pricing page and not guaranteed to be accurate.

Features

The purpose of this library is to provide a convenient interface for exploring web scraping with GPT.

While the bulk of the work is done by the GPT model, scrapeghost provides a number of features to make it easier to use.

Python-based schema definition - Define the shape of the data you want to extract as any Python object, with as much or little detail as you want.

Preprocessing

  • HTML cleaning - Remove unnecessary HTML to reduce the size and cost of API requests.
  • CSS and XPath selectors - Pre-filter HTML by writing a single CSS or XPath selector.
  • Auto-splitting - Optionally split the HTML into multiple calls to the model, allowing for larger pages to be scraped.

Postprocessing

  • JSON validation - Ensure that the response is valid JSON. (With the option to kick it back to GPT for fixes if it's not.)
  • Schema validation - Go a step further, use a pydantic schema to validate the response.
  • Hallucination check - Does the data in the response truly exist on the page?

Cost Controls

  • Scrapers keep running totals of how many tokens have been sent and received, so costs can be tracked.
  • Support for automatic fallbacks (e.g. use cost-saving GPT-3.5-Turbo by default, fall back to GPT-4 if needed.)
  • Allows setting a budget and stops the scraper if the budget is exceeded.

Project details


Download files

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

Source Distribution

scrapeghost-0.5.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

scrapeghost-0.5.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file scrapeghost-0.5.0.tar.gz.

File metadata

  • Download URL: scrapeghost-0.5.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.2 Darwin/21.6.0

File hashes

Hashes for scrapeghost-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9c1d190edb0be709e2d87352afba3fff6528ebd2aa4f9947d903b4a1f843cb7a
MD5 5e5ae1e29a8ea5cac9a9699f3398dedb
BLAKE2b-256 edbbc8dfd1a648dce912b52a1af85b8a0406ef68ad45c0183820aaa47b5c5932

See more details on using hashes here.

File details

Details for the file scrapeghost-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: scrapeghost-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.2 Darwin/21.6.0

File hashes

Hashes for scrapeghost-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbd11815383245887129c1b1d69b2f2c39800cce0ec614f99fb0d02035e02dbb
MD5 c19448111f9c2a99230cfc3f5f95d09e
BLAKE2b-256 8dddbe415d4d8b2a204ff2eddb99cd1fe6ea17a6b40538e6ad60f82ece388317

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page