Python BeautifulSoup-获取onmouseover属性



我想从包含属性"onmouseover"的标记中获取javascript函数名。例如:

<p onmouseover="test_hover2()" />Title<p>
<img src="esel.png" onmouseover="test_hover()" id="logo" />

我试过了:

for tag in soup.findAll(onmouseover=True):
    print tag.onmouseover

我想要的结果是"test_hover2(),test_hover()"。但它返回无

我能做什么?

tag['onmouseover']

HTML属性在Python中转换为BS对象中的键。BS对象的属性是HTML子对象。希望这是有意义的。。。

最新更新