Skip to main content

Base library for scrapy's ItemLoader

Project description

PyPI Version Supported Python Versions CI Status Coverage report 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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itemloaders-1.3.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

itemloaders-1.3.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file itemloaders-1.3.1.tar.gz.

File metadata

  • Download URL: itemloaders-1.3.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for itemloaders-1.3.1.tar.gz
Algorithm Hash digest
SHA256 81571c941cc189bb55e211f0cd3476fde7511239d3bf7ff91eb6ed68a1b0ec10
MD5 16be5a1fa002880b725089a5ee746cc9
BLAKE2b-256 17cd1cdef11f36a0a6c3db2bbfc28e5e10b358aeae54f6c2279dd89c595ebf56

See more details on using hashes here.

Provenance

File details

Details for the file itemloaders-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: itemloaders-1.3.1-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.3

File hashes

Hashes for itemloaders-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70be155cd050b8c532e1054f0241dcc4711bd15e62c0a0174963d1c110d9f0fa
MD5 af79c5070231c55e2c97a6da17f5cce1
BLAKE2b-256 6f3d5fef602e1f89dd2d48551609432809fcf791a63b304177b8193165c04b23

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page