Skip to main content

Base library for scrapy's ItemLoader

Project description

PyPI Version Supported Python Versions Build 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

    • 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.0.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

itemloaders-1.0.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: itemloaders-1.0.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.0

File hashes

Hashes for itemloaders-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f5b315d24322b6a0d9150c4d74f92f93b1bd5247bc0ce64c2b46de30710df211
MD5 0914f14b6196f1ea8ce8d35ca19fe3ce
BLAKE2b-256 56b83964dbd7809e9ee6f9f1cfc3b9dffbd44e12cc4dbec64fa4d2f7964f3fe5

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: itemloaders-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.0

File hashes

Hashes for itemloaders-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7adf0f4b668c784e8a7d872c7650f238a37ee578ba16e05dde2a03b5a2c4cd5a
MD5 8aef53914b6bbc97690c62e40cf19cad
BLAKE2b-256 a8533855a2f5496d8effe895ba87eced19984501dd00f289b5048040b87bb542

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