找到BeautifulSoup特定标签 [英] Find a specific tag with BeautifulSoup

查看:229
本文介绍了找到BeautifulSoup特定标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以很容易BS穿越通用的标签,但我不知道如何找到特定的标签。例如,我怎么能找到&LT的所有出现; DIV的风格=WIDTH = 300像素;> ?这可能与BS?

I can traverse generic tags easily with BS, but I don't know how to find specific tags. For example, how can I find all occurances of <div style="width=300px;">? Is this possible with BS?

推荐答案

下面应该工作

soup = BeautifulSoup(htmlstring)
soup.findAll('div', style="width=300px;")

有两种方法来搜索标记。

There are couple of ways to search for tags.

有关更多的文字来了解并使用它

For more text to understand and use it

  • http://lxml.de/elementsoup.html

这篇关于找到BeautifulSoup特定标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆