【发布时间】:2020-03-05 04:58:15
【问题描述】:
我正在从这个页面抓取信息:
https://lawyers.justia.com/lawyer/michael-paul-ehline-85006 。
我正在尝试在费用部分下抓取所有信息。
我想要的是以下信息:
免费咨询
是的
接受信用卡
维萨卡、万事达卡、美国运通卡
或有费用
仅在人身伤害案件中。
费率、固定器和其他信息
费率因情况而异。
这是我尝试过的:
for thing in soup.findAll('ul', attrs={"class": "has-no-list-styles"}):
ul=thing.find('<li>')
print(ul)
但输出是:
<li>Intellectual Property</li>
<li>Copyright Law</li>
<li><strong>English</strong></li>
提前谢谢你。
更新:我找到了一个解决方案,但它给了我一个无限循环,有什么建议吗?
for o in soup.findAll('div', attrs={"class": "block-wrapper"}):
for tag in soup.findAll('div', attrs={"class": "block-wrapper"}):
if tag.string:
tag.string.replace_with("")
for de in o.findAll("li"):
if de != []:
de=remove_tags(str(de))
print (de)
【问题讨论】:
-
"heading-3 block-title iconed-heading font-w-bold" 在这个 div 类中使用 Blocks 类,然后继续使用 thing.find() 作为 span 和 li 标签。
-
您一次又一次地调用“soup.findAll”两次尝试将第二个“soup.findAll”更改为“o.findAll”
-
@Abe 当我将其更改为 o.findAll 时,它会吐出几乎完全相同的东西
标签: python web beautifulsoup scrape