我正在尝试进行一些网络抓取,然后运行两个for循环来深入研究,我最终想要的是网络链接href。
website_details = soup.find_all("div", attrs={'class': 'bodyText'})
result = []
for tag in website_details:
result.append(tag)
result2 = []
p_tag = result.find_all("p")
for tag in p_tag:
result2.append(tag)
我收到以下错误。
p_tag = result.find_all(“p”)
AttributeError:'list'对象没有属性'find_all'
答案 0 :(得分:3)
这是因为result
是python list
而list
没有find_all()
函数。
您需要在汤品上调用find_all()
(可能在website_details
上?)。