- Notifications
You must be signed in to change notification settings - Fork155
Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
License
NotificationsYou must be signed in to change notification settings
scrapy/parsel
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Parsel is a BSD-licensedPython library to extract data fromHTML,JSON, andXML documents.
It supports:
- CSS andXPath expressions for HTML and XML documents
- JMESPath expressions for JSON documents
- Regular expressions
Find the Parsel online documentation athttps://parsel.readthedocs.org.
Example (open online demo):
>>>from parselimport Selector>>> text="""...<html>...<body>...<h1>Hello, Parsel!</h1>...<ul>...<li><a href="http://example.com">Link1</a></li>...<li><a href="http://scrapy.org">Link2</a></li>...</ul>...<scripttype="application/json">{"a": ["b","c"]}</script>...</body>...</html>""">>> selector= Selector(text=text)>>> selector.css("h1::text").get()'Hello, Parsel!'>>> selector.xpath("//h1/text()").re(r"\w+")['Hello', 'Parsel']>>>for liin selector.css("ul > li"):...print(li.xpath(".//@href").get())...http://example.comhttp://scrapy.org>>> selector.css("script::text").jmespath("a").get()'b'>>> selector.css("script::text").jmespath("a").getall()['b', 'c']
About
Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.