Skip to main content

Crawl and scrape websites with a given .json schema.

Project description

Jaydee

Crawl websites and scrape HTML documents using a .json file schema.

Installation

Make sure you have playwright installed with:

$ pip install playwright
$ playwright install

Currently Jaydee runs on chromium so make sure that playwright at least installs that as a webdriver.

Afterwards install Jaydee from PIP:

$ pip install jaydee

Usage

More in-depth usage examples can be found in the examples directory.

Crawling:

import asyncio

from jaydee.crawler import Crawler


async def main():
    # on_proceed is called once the crawlers url queue is empty.
    def on_proceed(crawler):
        # Add pages after crawler has extracted links.
        # this page is only added once since crawler keeps track of pages it has visited.
        crawler.add_url("https://www.example.com/foo")

    crawler = Crawler(
        "https://www.example.com",
        on_proceed,
    )

    async for result in crawler.start():
        print(f"Metadata: {result["metadata"]}")
        print(f"Links found: {result["links"]}")


def start():
    asyncio.run(main())

Scraping example with requests:

import requests

from jaydee import Scraper

# Retrieve an HTML document.
r = requests.get("https://example.com")

# Setup the scraper with rules according to a .json file.
scraper = Scraper(html_doc=r.content).from_json("data/rules.json")

# Get a result
result = scraper.scrape()

License

This repository is licensed under the MIT license.

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

jaydee-0.1.4.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

jaydee-0.1.4-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jaydee-0.1.4.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for jaydee-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9f7bb85232c83bfa1f18838ac1fafecba80e20752938e18bb4131953f14477a0
MD5 14cead18d43a179cffc7400c7b4633fd
BLAKE2b-256 9868a5b1ce937616147fbb440d4a2d17f33b84bba7fe771cbb07dfdea51cf08b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jaydee-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for jaydee-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ed6019d68f4e07ac2a476782a3a0942ee5d9a510a306e1814a65f84487275fa9
MD5 7bc77e5d6d0ab17cb670ba81ddc9aa15
BLAKE2b-256 93104fee6e9f422e8a52cd1879392b679790fde4c642c0452944a289201229be

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