<li><a class="atc-group atc-group-active" href="" data-url="/atc-kodlari/1">
<i class="fa fa-lg fa-pulse fa-spinner atc-group-loading" style="margin-right: 5px; display: none;"></i>
<span class="lists-rundown-no">(16)</span>
</a>
<i class="fa fa-lg fa-pulse fa-spinner atc-group-loading" style="margin-right: 5px; display: none;"></i>
<span class="lists-rundown-no">(16)</span>
<a class="atc-group atc-group-active" href="" data-url="/atc-kodlari/1">
<i class="fa fa-lg fa-pulse fa-spinner atc-group-loading" style="margin-right: 5px; display: none;"></i>
HERE!!
<span class="lists-rundown-no">(16)</span>
</a></li>
我要演写在这里的角色!!在python上使用漂亮的soup,但它是一个散乱的文本,所以它没有选择器或其他东西。有可能得到那个吗?你知道吗
我试过的。你知道吗
import requests
from bs4 import BeautifulSoup
r = requests.get('anywebsite')
source = BeautifulSoup(r.content,"lxml")
for child in source.select("#atc-wrapper > ul"):
for child2 in child.findChildren():
print(child2)
根据显示的html,您可以使用
next_sibling
并更改css选择器您可以使用CSS选择器
a:last-of-type i
来选择最后一个元素<a>
中的元素<i>
。然后将find_next()
与参数text=True
一起使用:印刷品:
进一步阅读:
CSS Selectors Reference
相关问题 更多 >
编程相关推荐