Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > ee1c13e5c16072cbf354daaedc0db0cd > files > 26

python3-parsel-1.5.1-2.mga7.noarch.rpm

===============================
Parsel
===============================

.. image:: https://img.shields.io/travis/scrapy/parsel/master.svg
   :target: https://travis-ci.org/scrapy/parsel
   :alt: Build Status

.. image:: https://img.shields.io/pypi/v/parsel.svg
   :target: https://pypi.python.org/pypi/parsel
   :alt: PyPI Version

.. image:: https://img.shields.io/codecov/c/github/scrapy/parsel/master.svg
   :target: http://codecov.io/github/scrapy/parsel?branch=master
   :alt: Coverage report


Parsel is a library to extract data from HTML and XML using XPath and CSS selectors

* Free software: BSD license
* Documentation: https://parsel.readthedocs.org.

Features
--------

* Extract text using CSS or XPath selectors
* Regular expression helper methods

Example::

    >>> from parsel import Selector
    >>> sel = Selector(text=u"""<html>
            <body>
                <h1>Hello, Parsel!</h1>
                <ul>
                    <li><a href="http://example.com">Link 1</a></li>
                    <li><a href="http://scrapy.org">Link 2</a></li>
                </ul
            </body>
            </html>""")
    >>>
    >>> sel.css('h1::text').get()
    'Hello, Parsel!'
    >>>
    >>> sel.css('h1::text').re('\w+')
    ['Hello', 'Parsel']
    >>>
    >>> for e in sel.css('ul > li'):
    ...     print(e.xpath('.//a/@href').get())
    http://example.com
    http://scrapy.org