Jan*_*ane 22 python beautifulsoup
我可以轻松地使用BS遍历通用标签,但我不知道如何查找特定标签.例如,我怎样才能找到所有出现的<div style="width=300px;">?这可能与BS有关吗?
pyf*_*unc 31
以下应该有效
soup = BeautifulSoup(htmlstring)
soup.findAll('div', style="width=300px;")
Run Code Online (Sandbox Code Playgroud)
有几种方法可以搜索标签.
有关更多文本要理解和使用它
与bs4的事情有所改变.所以代码应该是这样的
soup = BeautifulSoup(htmlstring,'lxml')
soup.find_all('div', {'style':"width=300px;"})
| 归档时间: |
|
| 查看次数: |
36704 次 |
| 最近记录: |