Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
docs/ | H | 25-Oct-2018 | - | 1,811 | 1,202 | |
parsel/ | H | 25-Oct-2018 | - | 640 | 505 | |
parsel.egg-info/ | H | 03-May-2022 | - | 257 | 184 | |
tests/ | H | 03-May-2022 | - | 1,105 | 878 | |
LICENSE | H A D | 25-Oct-2018 | 1.5 KiB | 28 | 22 | |
MANIFEST.in | H A D | 25-Oct-2018 | 237 | 12 | 9 | |
NEWS | H A D | 25-Oct-2018 | 4.6 KiB | 177 | 118 | |
PKG-INFO | H A D | 25-Oct-2018 | 8.9 KiB | 257 | 184 | |
README.rst | H A D | 25-Oct-2018 | 1.4 KiB | 52 | 41 | |
setup.cfg | H A D | 25-Oct-2018 | 86 | 11 | 7 | |
setup.py | H A D | 25-Oct-2018 | 2.6 KiB | 83 | 70 |
README.rst
1=============================== 2Parsel 3=============================== 4 5.. image:: https://img.shields.io/travis/scrapy/parsel/master.svg 6 :target: https://travis-ci.org/scrapy/parsel 7 :alt: Build Status 8 9.. image:: https://img.shields.io/pypi/v/parsel.svg 10 :target: https://pypi.python.org/pypi/parsel 11 :alt: PyPI Version 12 13.. image:: https://img.shields.io/codecov/c/github/scrapy/parsel/master.svg 14 :target: http://codecov.io/github/scrapy/parsel?branch=master 15 :alt: Coverage report 16 17 18Parsel is a library to extract data from HTML and XML using XPath and CSS selectors 19 20* Free software: BSD license 21* Documentation: https://parsel.readthedocs.org. 22 23Features 24-------- 25 26* Extract text using CSS or XPath selectors 27* Regular expression helper methods 28 29Example:: 30 31 >>> from parsel import Selector 32 >>> sel = Selector(text=u"""<html> 33 <body> 34 <h1>Hello, Parsel!</h1> 35 <ul> 36 <li><a href="http://example.com">Link 1</a></li> 37 <li><a href="http://scrapy.org">Link 2</a></li> 38 </ul 39 </body> 40 </html>""") 41 >>> 42 >>> sel.css('h1::text').get() 43 'Hello, Parsel!' 44 >>> 45 >>> sel.css('h1::text').re('\w+') 46 ['Hello', 'Parsel'] 47 >>> 48 >>> for e in sel.css('ul > li'): 49 ... print(e.xpath('.//a/@href').get()) 50 http://example.com 51 http://scrapy.org 52