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 directory examples.

Crawling:

import asyncio

from src.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.
        crawler.add_url("https://www.example.com/foo")

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

    async for link in crawler.start():
        print(link)


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

Scraping:

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.2.tar.gz (10.8 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.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jaydee-0.1.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.6 Windows/11

File hashes

Hashes for jaydee-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ccf2fe5550207510e5cf88c994edb1506cb5ae508940d867e0fc1c5aaa4a25a4
MD5 9c998fb92fa84819c1812dbd45686afe
BLAKE2b-256 d29e499184a5c66ad02598f6c0b4a503c785b5858ffc298a47f64a6fc1cb4776

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jaydee-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.6 Windows/11

File hashes

Hashes for jaydee-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85ff5ff8fd00bd93a3460ed78e064c01c67fee52d2b3be70a309cd0a5320ecb4
MD5 4fa160cfe829b4eb2f434e722c30eada
BLAKE2b-256 7ec2fbd7cc5f9ada8ddcba60bde69f0cb8c8230d4fcb5a6749a9a378f659f8d3

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