Base library for scrapy's ItemLoader
Project description
itemloaders is a library that helps you collect data from HTML and XML sources.
It comes in handy to extract data from web pages, as it supports data extraction using CSS and XPath Selectors.
It’s specially useful when you need to standardize the data from many sources. For example, it allows you to have all your casting and parsing rules in a single place.
Here is an example to get you started:
from itemloaders import ItemLoader from parsel import Selector html_data = ''' <!DOCTYPE html> <html> <head> <title>Some random product page</title> </head> <body> <div class="product_name">Some random product page</div> <p id="price">$ 100.12</p> </body> </html> ''' loader = ItemLoader(selector=Selector(html_data)) loader.add_xpath('name', '//div[@class="product_name"]/text()') loader.add_xpath('name', '//div[@class="product_title"]/text()') loader.add_css('price', '#price::text') loader.add_value('last_updated', 'today') # you can also use literal values item = loader.load_item() item # {'name': ['Some random product page'], 'price': ['$ 100.12'], 'last_updated': ['today']}
For more information, check out the documentation.
Contributing
All contributions are welcome!
If you want to review some code, check open Pull Requests here
If you want to submit a code change
File an issue here, if there isn’t one yet
Fork this repository
Create a branch to work on your changes
Run pre-commit install to install pre-commit hooks
Push your local branch and submit a Pull Request
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
File details
Details for the file itemloaders-1.3.2.tar.gz
.
File metadata
- Download URL: itemloaders-1.3.2.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4faf5b3abe83bf014476e3fd9ccf66867282971d9f1d4e96d9a61b60c3786770 |
|
MD5 | 07e11fabfc7d85ff84d6e22abcb26eb5 |
|
BLAKE2b-256 | b63ec549370e95c9dc7ec5e155c075e2700fa75abe5625608a4ce5009eabe0bf |
File details
Details for the file itemloaders-1.3.2-py3-none-any.whl
.
File metadata
- Download URL: itemloaders-1.3.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a91465f721c7bad8b07e1fbb0560cf99f4845156ed9f7bf2ca424336c6a677c |
|
MD5 | 346c3cb185c154eea704febe3c1dd648 |
|
BLAKE2b-256 | d5689592dcfd9c24467b545fac17b098a171e372bf0d775400fa1971712bca57 |