是否有更好的方法来构建此刮擦?

问题描述 投票:0回答:1

仍然学习如何使用BeautifulSoup和Python进行网络抓取。我想出了这一点来从此网站https://lawyers.justia.com/lawyer/ali-shahrestani-esq-198352中获取专业经验。

for item in soup.findAll("dl",attrs={"class":"description-list list-with-badges"}):
    x=item.findAll("strong")
    x=remove_tags(str(x))
    print(x)

输出:

[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[Attorney]
[]
[]
[]
[]
[]
[]
[]
[]
[]

我也希望在“律师”下获得相关信息,但我一直在努力。

python beautifulsoup scrape
1个回答
0
投票

[您可以使用if x:过滤数据,以后可以使用item进行其他操作

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.