仍然学习如何使用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]
[]
[]
[]
[]
[]
[]
[]
[]
[]
我也希望在“律师”下获得相关信息,但我一直在努力。
[您可以使用if x:
过滤数据,以后可以使用item
进行其他操作