您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python中类似jquery的HTML解析?

Python中类似jquery的HTML解析?

如果您能熟练使用BeautifulSoup,则只需将soupselect添加到您的库中。 Soupselect是BeautifulSoup的CSS选择器扩展。

用法

>>> from BeautifulSoup import BeautifulSoup as Soup
>>> from soupselect import select
>>> import urllib
>>> soup = Soup(urllib.urlopen('http://slashdot.org/'))
>>> select(soup, 'div.title h3')
[<h3><span><a href='//science.slashdot.org/'>Science</a>:</span></h3>,
 <h3><a href='//slashdot.org/articles/07/02/28/0120220.shtml'>Star Trek</h3>,
..]
python 2022/1/1 18:47:01 有306人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶