Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scrapy/itemloaders
Library to populate items using XPath and CSS with a convenient API
https://github.com/scrapy/itemloaders
hacktoberfest
Last synced: 3 months ago
JSON representation
Library to populate items using XPath and CSS with a convenient API
- Host: GitHub
- URL: https://github.com/scrapy/itemloaders
- Owner: scrapy
- License: bsd-3-clause
- Created: 2020-04-17T13:24:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-04T07:00:16.000Z (5 months ago)
- Last Synced: 2024-07-20T00:09:53.588Z (4 months ago)
- Topics: hacktoberfest
- Language: Python
- Homepage:
- Size: 316 KB
- Stars: 44
- Watchers: 9
- Forks: 15
- Open Issues: 21
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-scrapy - itemloaders
README
===========
itemloaders
===========.. image:: https://img.shields.io/pypi/v/itemloaders.svg
:target: https://pypi.python.org/pypi/itemloaders
:alt: PyPI Version.. image:: https://img.shields.io/pypi/pyversions/itemloaders.svg
:target: https://pypi.python.org/pypi/itemloaders
:alt: Supported Python Versions.. image:: https://github.com/scrapy/itemloaders/workflows/CI/badge.svg?branch=master
:target: https://github.com/scrapy/itemloaders/actions?workflow=CI
:alt: CI Status.. image:: https://codecov.io/github/scrapy/itemloaders/coverage.svg?branch=master
:target: https://codecov.io/gh/scrapy/itemloaders
:alt: Coverage report.. image:: https://readthedocs.org/projects/itemloaders/badge/?version=latest
:target: https://itemloaders.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status``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 Selectorhtml_data = '''
Some random product page
Some random product page
$ 100.12
'''
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