Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Repository files navigation

TestsSupported Python versionsPyPI VersionCoverage report

Parsel is a BSD-licensedPython library to extract data fromHTML,JSON, andXML documents.

It supports:

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

Stars

Watchers

Forks

Packages

No packages published

Contributors50

Languages


[8]ページ先頭

©2009-2025 Movatter.jp