【发布时间】:2020-01-19 06:27:26
【问题描述】:
我正在尝试获取此 div 中的第二个跨度值和其他类似的值(如下所示)
<div class="C(#959595) Fz(11px) D(ib) Mb(6px)">
<span>VALUE 1</span>
<i aria-hidden="true" class="Mx(4px)">•</i>
<span>TRYING TO GET THIS</span>
</div>
我试过查看类似的堆栈帖子,但我仍然不知道如何解决这个问题。 这是我当前的代码:
time = soup.find_all('div', {'class': 'C(#959595) Fz(11px) D(ib) Mb(6px)'})
for i in time:
print(i.text) #this prints VALUE 1 x amount of times (there are multiple divs)
我尝试过 i.span、i.contents、i.children 等。 非常感谢任何帮助,谢谢!
【问题讨论】:
-
您查阅过 BeatifulSoup 文档吗?
标签: python web-scraping beautifulsoup html-parsing