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.

Features:

  • Scrape websites flexibly by with .json schemas.
  • Scrape git repositories and store the code content.

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 for links:

import asyncio

from jaydee.crawlers import LinkCrawler


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 = LinkCrawler(
        "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.11.tar.gz (14.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.11-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jaydee-0.1.11.tar.gz
  • Upload date:
  • Size: 14.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.11.tar.gz
Algorithm Hash digest
SHA256 be7f2eb5001787ef46bfd86c269e8be127a59066bbfc0ab5e8f22e624eb2f1eb
MD5 dcfb8c494b5c10486bec7445e56c5aa0
BLAKE2b-256 cb12893cfb7c978cbbc8893c4eee879e99569595908ef5a4e764ca428c2b5faa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jaydee-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 18.5 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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 6c57656e86e7c83e72acae69d59b14f97217f5397e472119c2f24db698f0668f
MD5 56fbdb478927185f7d126babc83e4c58
BLAKE2b-256 4627f3e4b08452331493238d43a047ec84999e940c48a7ae558683feaa93c5e7

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