我试图在web上搜索grofer和bigbasket信息,但我在使用findAll()函数时遇到了问题。当我使用len(imgList)时,长度总是返回0。它总是显示空列表如何解决它?有人能帮我吗?我在格罗夫得到了staus代码403
from bs4 import BeautifulSoup
url = 'https://grofers.com/cn/grocery-staples/cid/16'
driver = webdriver.Chrome(r'C:\Users\HP\data\chromedriver.exe')
driver.get(url)
html = driver.page_source
soup = BeautifulSoup(html,'html.parser')
data = soup.findAll('plp-product__name')
print(data)
from bs4 import BeautifulSoup
response = requests.get('https://grofers.com/cn/grocery-staples/cid/16')
response
content = response.content
data = BeautifulSoup(content,'html5lib')
read = data.findAll('plp-product__name ')
read```
在输出中,我得到:
[]
你没有包括在内
试一试
或者
注意,正确的方法是
find_all
而不是findAll
,因为它在bs4库中被弃用相关问题 更多 >
编程相关推荐