【问题标题】:'NoneType' object is not for beautifulsoup'NoneType' 对象不适用于 beautifulsoup
【发布时间】:2020-06-10 16:47:35
【问题描述】:

我正在尝试网页抓取。然而,由于这个错误无法继续。如果有人能帮我解决这个问题,我会很好。

这是我的代码。

from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
my_url = "https://www.newegg.com/Video-Cards-Video-Devices/Category/ID-38?Tpk=graphics%20card"

uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
#html parsing
page_soup = soup(page_html,"html.parser")
containers = page_soup.findALL("div",{"class":"item-branding"})

下面是错误


TypeError Traceback(最近一次调用最后一次) 在 13 14 ---> 15 个容器 = page_soup.findALL("div",{"class":"item-branding"}) 16长(集装箱) 17

TypeError: 'NoneType' 对象不可调用

【问题讨论】:

  • 尝试使用find_all 而不是findALL...!
  • 进展如何??

标签: python-3.x web-scraping beautifulsoup


【解决方案1】:

它是 page_soup.findAll("div",{"class":"item-branding"}) 。不是page_soup.findALL("div",{"class":"item-branding"})(注意小“l”)

【讨论】:

    猜你喜欢
    • 2016-10-10
    • 1970-01-01
    • 2015-07-03
    • 2019-01-12
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-06
    相关资源
    最近更新 更多