【发布时间】:2018-11-05 02:22:39
【问题描述】:
我在使用 HTML 5.0 获取 Beautifulsoup 中属性值的正确语法时遇到了困难。
所以我已经在我的soup 中使用正确的语法隔离了标签的出现,其中存在 HTML 5 问题:
tags = soup.find_all(attrs={"data-topic":"recUpgrade"})
只取标签[1]:
date = tags[1].find(attrs={"data-datenews":True})
这里的日期是:
<span class="invisible" data-datenews="2018-05-25 06:02:19" data-idnews="2736625" id="horaCompleta"></span>
但现在我想提取日期时间“2018-05-25 06:02:19”。无法获取语法。
请提供见解/帮助。
【问题讨论】:
-
可以从元素中获取属性值,查看this
标签: python beautifulsoup