Skip to main content

Lightweight web scraper with rate limiting and CSS selectors

Project description

philiprehberger-web-scraper

Lightweight web scraper with rate limiting and CSS selectors.

Install

pip install philiprehberger-web-scraper

Usage

from philiprehberger_web_scraper import Scraper

scraper = Scraper(rate_limit=2.0, retry_attempts=3)

# Fetch a single page
page = scraper.get("https://example.com")
titles = page.select_all("h2.title")
link = page.select_one("a.next")
all_links = page.links()

# Extract data
for el in page.select_all(".product"):
    print(el.select_one(".name").text)
    print(el.select_one("a").attr("href"))

# Crawl multiple pages
for page in scraper.crawl("https://example.com/blog", max_pages=20):
    for article in page.select_all("article"):
        print(article.select_one("h2").text)

# Export
Scraper.export_csv(data, "output.csv")
Scraper.export_json(data, "output.json")

Features

  • Built-in rate limiting (token bucket)
  • Retry with backoff on 429/5xx errors
  • CSS selector API wrapping BeautifulSoup
  • Crawl mode with same-domain filtering
  • Link and image extraction
  • CSV and JSON export helpers

Options

Scraper(
    rate_limit=2.0,        # max requests/second
    retry_attempts=3,      # retries on failure
    retry_delay=1.0,       # base delay between retries
    timeout=30.0,          # request timeout
    headers={...},         # custom headers
)

License

MIT

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

philiprehberger_web_scraper-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_web_scraper-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_web_scraper-0.1.1.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_web_scraper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ccd7f40a6596838745ec0a137a3aa4e45c94d9887f33658606e4862534a104f5
MD5 90b5740a498bdaf2ecb863ebb976de54
BLAKE2b-256 d51cb546d55c7d5aab932c6365d72bd0dc385302358e88774b3fac72ac693c00

See more details on using hashes here.

File details

Details for the file philiprehberger_web_scraper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_web_scraper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd994c4ace0d1884d346eeb317d4cc8f98d636127fe4c3cc802fe0c371f8505b
MD5 2775ffdd4331af863147f9884b7127fa
BLAKE2b-256 11c9a356e663b18c9e0380ad677a0a3adc9e0de2d5489ecd796e4f8ec70e9d3a

See more details on using hashes here.

Supported by

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