【发布时间】:2021-09-28 02:21:53
【问题描述】:
大家好,这里的新 Python 学习者需要 BeautifulSoup 的帮助
我想从上面链接中显示的 sn-p 中打印 "li","class":"keypoint" 中的 "Resale" 文本,并在不存在的地方打印 none。我可以在 python 的 for 循环中使用下面的代码提取 old 和浴室
try:
print("Age :", item.find("li", {'class': "keypoint", "title": "old"}).text)
except:
print("Age :", "Not Mentioned")
try:
print("Bathrooms :", item.find("li", {'class': "keypoint", "title": "Bathrooms"}).text)
except:
print("Bathrooms :", "Not Mentioned")
谁能告诉我如何从 span 中获取“转售”文本?
【问题讨论】:
-
@Wondercricket 谢谢你的工作!!!
标签: python web-scraping beautifulsoup