我想提取的数据来自这个网站https://www.adobe.com/support/security/advisories/apsa11-04.html。 我只想提取
Release date: December 6, 2011 Last updated: January 10, 2012 Vulnerability identifier: APSA11-04 CVE number: CVE-2011-2462
守则:
from bs4 import BeautifulSoup
div = soup.find("div", attrs={"id": "L0C1-body"})
for p in div.findAll("p"):
if p.find('strong'):
print(p.text)
输出:
Release date: December 6, 2011
Last updated: January 10, 2012
Vulnerability identifier: APSA11-04
CVE number: CVE-2011-2462
Platform: All
*Note: Adobe Reader for Android and Adobe Flash Player are not affected by this issue.
我不想要这个信息。我应该如何过滤它
Platform: All *Note: Adobe Reader for Android and Adobe Flash Player are not affected by this issue.
如果您知道希望始终在
<h2>
标记之后使用前4个<p>
标记,则可以使用以下示例:印刷品:
我不会检索整个集合,而是使用:nth-of-type对选择器本身中的前4个同级p标记进行更有效的筛选:
您还可以使用limit argument:
相关问题 更多 >
编程相关推荐