有没有一种方法可以解决对象没有atribute FindAll()的问题



我正在尝试构建一个简单的web scraper,但FindAll((总是出错。我想我的问题可能是BS4。不太确定。。。

我的代码是:

my_url = 'https://www.newegg.ca/p/pl?d=graphics+cards&N=100007708&name=Desktop%20Graphics%20Cards'

uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, 'html.parser')
container = page_soup.findall('div', {'class':'item-info'})
len(container)

我面临这个错误:

Traceback (most recent call last):
File "C:/Users/PycharmProjects/Web_Scraper/Web_Scraper.py", line 12, in <module>
container = page_soup.re.findall('div', {'class':'item-info'})
AttributeError: 'NoneType' object has no attribute 'findall'

如果将findall替换为find_all,错误将得到解决。

最新更新