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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jaydee-0.1.9.tar.gz.
File metadata
- Download URL: jaydee-0.1.9.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61a392a464ea7122409890ac7545f4609b21829f9f26fc7d6e14abfd8cfafdfc
|
|
| MD5 |
28c0e382763ea043395a2ca06714db3f
|
|
| BLAKE2b-256 |
0351f3e0829aa8026d1a25ed35130c37c0d12400bbb7578d2ea3260b8abcdb64
|
File details
Details for the file jaydee-0.1.9-py3-none-any.whl.
File metadata
- Download URL: jaydee-0.1.9-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d705ba12c7c67495a72a841a9704354b316292e7c4642ada7f37f596e2e23968
|
|
| MD5 |
a82754ca4595205c3e33689ba27450d4
|
|
| BLAKE2b-256 |
a32e96c4696249e58af7794ad68ee53874e78460762b214b2e81aa4157c72985
|