使用BeautifulSoup进行Python Web Scraping。问题'tuple'对象没有属性'h1'和'p'

问题描述 投票:-5回答:1

enter image description here

您好,我有一个网站报废这个网址的问题我已经在我的代码编辑器中写了它,但也在cmd中这样做,因为我一直在努力确保我做对了。我遇到了一个问题:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'h1'

我也做了'p',看看它是否可以从页面上得到一个段落,但这也不值得。请检查上述问题。

谢谢你的帮助

python web-scraping beautifulsoup
1个回答
0
投票

改变这个:

page_soup = (uClient.read(), "html.parser")

至:

page_soup = soup(uClient.read(), "html.parser")

它创建了BeautifulSoup对象。

© www.soinside.com 2019 - 2024. All rights reserved.