Scrape HTML to dictionaries
Project description
Write scraping rules, get dictionaries.
scrapedict
is a Python module designed to simplify the process of writing web scraping code. The goal is to make scrapers easy to adapt and maintain, with straightforward and readable code.
Features
- The rules dictionary is straightforward and easy to read
- Once you define the rules for one item you can extract multiple items
- You get ✨dictionaries✨ of the data you want
Installation
$ pip install scrapedict
Usage
import requests
import scrapedict as sd
response = requests.get("https://www.urbandictionary.com/define.php?term=larping")
fields = {
"word": sd.text(".word"),
"meaning": sd.text(".meaning"),
"example": sd.text(".example"),
}
item = sd.extract(fields, response.text)
The orange site example
import requests
import scrapedict as sd
response = requests.get("https://news.ycombinator.com/")
fields = {
"title": sd.text(".titleline a"),
"url": sd.attr(".titleline a", "href"),
}
items = sd.extract_all(".athing", fields, response.text)
Development
Dependencies are managed with Poetry.
Testing is done with Tox.
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
scrapedict-0.2.1.tar.gz
(2.0 kB
view hashes)
Built Distribution
Close
Hashes for scrapedict-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b32fcda388cb9af478fe8d4fb544403d682e87c0de2928cd1f1f50be63ea3c20 |
|
MD5 | 2c09c62103be2e598e97ae49a369615c |
|
BLAKE2b-256 | 20b26c2a8d2f90d91f72ba349d83f3538ec02bb9d6d6d7fbe641e82793793097 |