Skip to main content

Parallel HTML Scraper

Test Test Coverage Maintainability Code Climate technical debt Updates PyPI - Python Version PyPI - Downloads Twitter URL

Helps you to web scrape html file in parallel without async / await syntax.

Feature

This project helps you to web scrape html file in parallel without async / await syntax.

Installation

pip install parallelhtmlscraper

Usage

Minimum example:

from bs4 import BeautifulSoup

from parallelhtmlscraper.html_analyzer import HtmlAnalyzer
from parallelhtmlscraper.parallel_html_scraper import ParallelHtmlScraper

class AnalyzerExample(HtmlAnalyzer):
    async def execute(self, soup: BeautifulSoup) -> str:
        return soup.find('title').text

host_google = 'https://www.google.com'
path_and_content = [
    '',                                                           # Google Search
    '/imghp?hl=EN',                                               # Google Images
    '/shopping?hl=en',                                            # Google Shopping
    '/save',                                                      # Collection
    'https://www.google.com/maps?hl=en',                          # Google Maps
    'https://www.google.com/drive/apps.html',                     # Google drive
    'https://www.google.com/mail/help/intl/en/about.html?vm=r',   # GMail
]

list_response = ParallelHtmlScraper.execute(host_google, path_and_content, AnalyzerExample())
print(list_response)
$ python test.py
['\n      Gmail - Email from Google\n    ', 'Google Images', '  Google Maps  ', 'Using Google Drive - New Features, Benefits & Advantages of Google Cloud Storage', 'Google Shopping', 'Google', 'Collections']

API

ParallelMediaDownloader.execute

class ParallelHtmlScraper:
    """API of parallel HTML scraping."""

    @staticmethod
    def execute(
        base_url: str,
        list_url: Iterable[str],
        analyzer: HtmlAnalyzer[_T],
        *,
        limit: int = 5
        interval: int = 1
    ) -> List[_T]:

base_url: str

Common part of request URL. This will be help to download URLs got from HTML.

list_url: Iterable[str]

List of URL. Method will download them in parallel. Absolute URL having same base URL as base_url also can be specified.

analyzer: HtmlAnalyzer[_T]

The instance extends HtmlAnalyzer to analyze HTML by using BeautifulSoup. Following example will be help to understand its roll:

class AnalyzerExample(HtmlAnalyzer):
    async def execute(self, soup: BeautifulSoup) -> str:
        return soup.find('title').text

limit: int = 5

Limit number of parallel processes.

interval: int = 1

Interval between each request(second).

Metadata

Release files for parallelhtmlscraper 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parallelhtmlscraper 0.2.0
File Size Uploaded Provenance Actions
parallelhtmlscraper-0.2.0.tar.gz 13.2 kB Without provenance Details for parallelhtmlscraper-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for parallelhtmlscraper 0.2.0
File Interpreter ABI Platform Actions
parallelhtmlscraper-0.2.0-py3-none-any.whl Python 3 none any Details for parallelhtmlscraper-0.2.0-py3-none-any.whl

Total release size: 23.0 kB

Release files / parallelhtmlscraper-0.2.0.tar.gz

Download URL parallelhtmlscraper-0.2.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8166f91075b44010ef9454ae0bbc74052b101320b43e1f51c0ed47f7ed6612f0
BLAKE2b-256 checksum
How to use checksums
c47dc56f788ec2ad9eb009c73e414d25ced0183e9f5308f8153500cdcbc58c8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / parallelhtmlscraper-0.2.0-py3-none-any.whl

Download URL parallelhtmlscraper-0.2.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43ff342de6443fb0e5822b13e930c243e24080a6428ccc8ce27f290520eb9001
BLAKE2b-256 checksum
How to use checksums
301f493bb0f6bd479ca408a30925b59a8d739739b70dd9b75d684e70d9066eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for parallelhtmlscraper 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page