【发布时间】:2020-07-17 09:51:21
【问题描述】:
我正在尝试从网络上抓取 grofer 和 bigbasket 信息,但我在 findAll() 函数中遇到了问题。当我使用 len(imgList) 时,长度总是返回 0。它总是显示空列表如何解决?谁能帮我解决这个问题?我在 grofer 中获得状态代码 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```
在输出中我得到:
[]
【问题讨论】:
标签: python selenium web-scraping