Skip to main content

No project description provided

Project description

Python Web Scraper

This script utilizes the Playwright library for scraping websites and generating a knowledgebase.

Main Function: scrape_website(config: Config)

Parameters

  • config: An object containing URLs to scrape, output file name, and a limit on pages to crawl.

Workflow

  1. Launch Chromium Browser: Uses Playwright to start a new browser instance.
  2. URL Iteration: For each URL in the Config object:
    • Sitemap Processing:
      • Navigate to sitemap.xml.
      • Raise NoSitemapError if not found, else extract URLs.
    • Page Processing: For each URL in the sitemap:
      • Stop if max_pages_to_crawl is reached.
      • Navigate to the URL and extract the page content.
      • Create a WebPage object with URL and content.
      • Clean content and add to Knowledgebase object.

Output Generation

  • Knowledgebase to JSON: Writes the Knowledgebase object to a JSON file.
  • Unique Filenames: Uses get_output_filename(file_name: str) to ensure unique file names.
  • Browser Closure: Closes the browser and proceeds to the next URL.
  • Error Handling: Prints NoSitemapError to console if encountered.

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

tedfulk_kb_pycrawler-0.1.4.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

tedfulk_kb_pycrawler-0.1.4-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file tedfulk_kb_pycrawler-0.1.4.tar.gz.

File metadata

  • Download URL: tedfulk_kb_pycrawler-0.1.4.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for tedfulk_kb_pycrawler-0.1.4.tar.gz
Algorithm Hash digest
SHA256 effa2dde11876facd8886427a36137e1ed8a29b734691b76ba77d96c551eebca
MD5 e584e339bf4521fdeaa4a146902609d9
BLAKE2b-256 a9b0f440d624dae722922ca5c8845080d088b30c4c6269441d2807605cf4fab3

See more details on using hashes here.

File details

Details for the file tedfulk_kb_pycrawler-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for tedfulk_kb_pycrawler-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6f23003075cab86ac7d8687a3d4ee1b0e0604b4cd73bb89cc42c5ee7c773848a
MD5 f459991af533a2cb330c10e6a03cbe3e
BLAKE2b-256 b692b6ebe9cf93574195fcd8e356384981d542478a7e4242ac19b615e53f6a75

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