Git Product home page Git Product logo

itemloaders's Introduction

itemloaders

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

itemloaders's People

Contributors

ejulio avatar gallaecio avatar pablohoffman avatar elacuesta avatar kmike avatar curita avatar mabelvj avatar dangra avatar pkufranky avatar wrar avatar dacjames avatar sortafreel avatar ammarnajjar avatar ngash avatar void avatar jdemaeyer avatar lopuhin avatar redapple avatar harshasrinivas avatar nyov avatar yarikoptic avatar rmax avatar matthijsy avatar allait avatar eliasdorneles avatar digenis avatar sudshekhar avatar noviluni avatar smirecki avatar nblock avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.