Skip to main content

WebWeaver

WebWeaver is a Python package for crawling and extracting URLs from web pages. It provides an easy-to-use interface for crawling a single page or an entire site, while handling errors and incomplete URLs gracefully. All crawling functionality is encapsulated within the WebWeaver class.

Features

  • crawl_url(url): Given a URL, this method returns a list of all URLs found on the page.
  • crawl_site(urls, limit, timeout): Crawls multiple URLs with the ability to limit the number of pages and set a timeout for each page to load. It returns an object of the UrlList class containing information about successfully crawled URLs, incomplete URLs, and error-causing URLs.
  • crawl_site_multiThreading(urls, limit, timeout, no_of_threads): Crawls multiple URLs using multithreading for faster performance, allowing you to control the number of threads. It returns an object of the UrlList class.

Installation

Install the package using pip:

pip install WebWeaver

Usage

WebWeaver Class

The WebWeaver class provides methods for URL extraction and site crawling.

crawl_url(url)

Extracts all URLs found on a given web page.

Parameters:

  • url (str): The URL of the page you want to crawl.

Returns:

  • list: A list of URLs found on the page.

Example:

from WebWeaver import WebWeaver

# Instantiate the WebWeaver class
weaver = WebWeaver()

# Crawl a single URL
urls = weaver.crawl_url("https://example.com")
print(urls)

crawl_site(urls, limit, timeout)

Crawls multiple web pages and returns an UrlList object that categorizes URLs into three sets: successfully crawled URLs, incomplete URLs, and URLs that caused errors.

Parameters:

  • urls (list): A list of URLs to start crawling.
  • limit (int): The maximum number of pages to crawl.
  • timeout (int): The time limit (in seconds) for each page to load.

Returns:

  • UrlList: An object containing three sets:
    • urls: A set of all successfully crawled and retrieved URLs.
    • abnormal_urls: A set of incomplete or malformed URLs extracted from the web pages.
    • error_urls: A set of URLs that caused errors when trying to make a request.

Example:

from WebWeaver import WebWeaver

# Instantiate the WebWeaver class
weaver = WebWeaver()

# Crawl multiple URLs
urls_to_crawl = ["https://example.com", "https://anotherexample.com"]
result = weaver.crawl_site(urls_to_crawl, limit=10, timeout=5)

# Accessing the sets from the result
print("Crawled URLs:", result.urls)
print("Abnormal URLs:", result.abnormal_urls)
print("Error URLs:", result.error_urls)

crawl_site_multiThreading(urls, limit, timeout, no_of_threads)

Crawls multiple web pages using multithreading, allowing for faster crawling by specifying the number of threads. Returns an UrlList object categorizing URLs into successfully crawled, incomplete, and error-causing URLs.

Parameters:

  • urls (list): A list of URLs to start crawling.
  • limit (int): The maximum number of pages to crawl.
  • timeout (int): The time limit (in seconds) for each page to load.
  • no_of_threads (int): The number of threads to use for crawling.

Returns:

  • UrlList: An object containing three sets:
    • urls: A set of all successfully crawled and retrieved URLs.
    • abnormal_urls: A set of incomplete or malformed URLs extracted from the web pages.
    • error_urls: A set of URLs that caused errors when trying to make a request.

Example:

from WebWeaver import WebWeaver

# Instantiate the WebWeaver class
weaver = WebWeaver()

# Crawl multiple URLs using multithreading
urls_to_crawl = ["https://example.com", "https://anotherexample.com"]
result = weaver.crawl_site_multiThreading(urls_to_crawl, limit=10, timeout=5, no_of_threads=16)

# Accessing the sets from the result
print("Crawled URLs:", result.urls)
print("Abnormal URLs:", result.abnormal_urls)
print("Error URLs:", result.error_urls)

UrlList Class

The crawl_site and crawl_site_multiThreading methods return an object of the UrlList class, which contains the following sets:

  • urls (set): A set of all successfully crawled URLs.
  • abnormal_urls (set): A set of incomplete or malformed URLs found during the crawl.
  • error_urls (set): A set of URLs that caused errors when attempting to access them.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.


Happy crawling!

Metadata

Release files for WebWeaver 1.2.3

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

Source distribution (sdist)

Source distribution for WebWeaver 1.2.3
File Size Uploaded Provenance Actions
webweaver-1.2.3.tar.gz 5.4 kB Without provenance Details for webweaver-1.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 11.4 kB

Release files / webweaver-1.2.3.tar.gz

Download URL webweaver-1.2.3.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8ac9432e6714bf0e000e421180c2b5d718998fdbaebd1375d6525db2c26f13db
BLAKE2b-256 checksum
How to use checksums
6746afeebf6f197c9003d42bfa5ada352916a69d642a6e4db4cbc984448c1a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / webweaver-1.2.3-py3-none-any.whl

Download URL webweaver-1.2.3-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e450538ac191fc5c7445711df314b193b6e193d27116b8371ef1ac5fd35cd6d
BLAKE2b-256 checksum
How to use checksums
ca66b1fea7b039dac3de2c058c6b5589da028b8716fd740dafe73041cb61301e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Security for WebWeaver 1.2.3

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