使用BeautifulSoup进行Python WebScraping。问题“元组”对象没有属性“ h1”和“ p”

时间:2019-03-15 19:29:44

标签: python web-scraping beautifulsoup

enter image description here

你好,我在用Web抓取此URL时遇到了一些问题,我一直在用代码编辑器编写它,但是在进行操作时也要使用cmd进行操作,以确保正确无误。我遇到一个问题,说:

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

我也做了'p'来看看是否可以从页面上删除一段,但是那也不值得。请检查上述问题。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

更改此:

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

收件人:

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

它将创建BeautifulSoup对象。