从urllib.request导入urlopen作为uReq从bs4进口BeautifulSoup作为汤导入re
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 =汤(page_html,'html.parser')
container = page_soup.findall('div',{'class':'item-info'})]
len(容器)
追踪(最近通话):文件“ C:/Users/PycharmProjects/Web_Scraper/Web_Scraper.py”,第12行container = page_soup.re.findall('div',{'class':'item-info'})AttributeError:“ NoneType”对象没有属性“ findall”
如果将findall
替换为find_all
,则错误将得到解决。