我正在尝试构建一个简单的Web抓取工具,并不断出现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'
答案 0 :(得分:1)
如果将findall
替换为find_all
,该错误将得到解决。