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.3a0.tar.gz (12.1 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.3a0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file jaydee-0.1.3a0.tar.gz.

File metadata

  • Download URL: jaydee-0.1.3a0.tar.gz
  • Upload date:
  • Size: 12.1 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.3a0.tar.gz
Algorithm Hash digest
SHA256 fd7287b1856b8fbebac4494852a3775886fa6f98929f6c5f4202f795b73d8bdf
MD5 922e8b9e2bb1e6e9faa6c21f321da480
BLAKE2b-256 5e13dcb9d85956076a882890622ac510dc73d63defb6a0f760fcdb3a57248119

See more details on using hashes here.

File details

Details for the file jaydee-0.1.3a0-py3-none-any.whl.

File metadata

  • Download URL: jaydee-0.1.3a0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 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.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3c9d0148864d24e7aab5e63e4f7c141a0966b511aeb3750cd12305b03ae0c63
MD5 8f7d0a0f835cf9ab9e1ce56b713093fc
BLAKE2b-256 794030b1057fe9688a0e9cbdaa667a8efb5444017109034a526f4944066891bd

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