Skip to main content

A mini web scraping utility package

Project description

pyminiscraper

Introduction

pyminiscraper is a lightweight Python library designed for easy web scraping. It provides a simple interface to extract data from web pages with minimal setup. Whether you are a beginner or an advanced user, pyminiscraper offers the flexibility to handle various scraping tasks efficiently.

Features

Feature Implemented
Basic Web Page scraping
Web Page spidering
Parallel requests
Headless browser support
Robots parsing
Sitemap parsing
RSS parsing
Atom parsing
Open Graph parsing
Rate limiting
Error handling
Depth control
Custom user agent
File storage
Custom callbacks
Domain restrictions
Request timeout
Page caching

Simplest Use Case

Here is a basic example of how to use pyminiscraper to scrape data from a web page:

from pyminiscraper.scraper import Scraper
from pyminiscraper.config import ScraperConfig

storage_dir.mkdir(parents=True, exist_ok=True)
click.echo(f"Storage directory set to: {storage_dir}")

scraper = Scraper(
    ScraperConfig(
        scraper_urls=[
            ScraperUrl(
                "https://www.anthropic.com/news", max_depth=2)
        ],
        max_parallel_requests=16,
        use_headless_browser=False,
        timeout_seconds=30,
        max_requests_per_hour=6*60,
        scraper_store_factory=FileStoreFactory(storage_dir.absolute().as_posix()),
    ),
)
await scraper.run()

Advanced Configuration Options

Configuration for web scraping behavior.

Parameters:

  • max_parallel_requests (int): Maximum number of concurrent scraping requests
  • max_requested_urls (int): Maximum total number of URLs to request before stopping
  • max_depth (int): Maximum depth for recursively following links (0 means only scrape seed URLs)
  • max_back_to_back_errors (int): Number of consecutive errors before terminating scraper
  • crawl_delay_seconds (float): Minimum delay between requests to same domain
  • request_timeout_seconds (float): Request timeout in seconds
  • user_agent (str): User agent string to use in requests
  • store_factory: Factory for creating storage backend
  • seed_urls (List[ScraperUrl]): Initial URLs to start scraping from
  • use_headless_browser (bool): Whether to use headless browser for JavaScript rendering
  • follow_web_page_links (bool): Whether to follow links found in web pages
  • follow_sitemap_links (bool): Whether to follow links found in sitemaps
  • follow_feed_links (bool): Whether to follow links found in RSS/Atom feeds
  • domain_config (DomainConfig): Configuration for allowed/blocked domains
  • log (Callable): Logging function to use

The scraper will:

  • Start with seed URLs and scrape them according to configuration
  • Follow links up to max_depth if follow_web_page_links is True
  • Follow sitemap.xml links if follow_sitemap_links is True
  • Follow RSS/Atom feed links if follow_feed_links is True
  • Respect robots.txt and crawl delay settings
  • Store results using provided store_factory
  • Stop when max_requested_urls is reached or max_back_to_back_errors occurs

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

pyminiscraper-1.0.1.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

pyminiscraper-1.0.1-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file pyminiscraper-1.0.1.tar.gz.

File metadata

  • Download URL: pyminiscraper-1.0.1.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pyminiscraper-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ad0743520d6765264926f3d0ec2bde0f6363e0e79a9a162377da017dd142b470
MD5 7e116b3b40c8a2a5da05a8819f70d6cf
BLAKE2b-256 4eddbb11673982e3441c7b4affd79a9951aa3125c8d4334250943134bcc842ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminiscraper-1.0.1.tar.gz:

Publisher: python-publish.yml on timurua/pyminiscraper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyminiscraper-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyminiscraper-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pyminiscraper-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1bc27862909a7ef42316feed0f3a8a45113611532fc41e6a6c08e8fc5936aa29
MD5 1ba010300ae9889c31d89a32b0845d67
BLAKE2b-256 ef63938c5f4bc43da891b5b6abeff9e2c128a23c73defa863fab374eef072a8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminiscraper-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on timurua/pyminiscraper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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