【发布时间】:2020-04-19 15:00:33
【问题描述】:
我是 Python 和 BeautifulSoup4 的新手。另外,我不了解 HTML。为了练习,我试图在 Carrefour 网站上使用它来提取我搜索 EAN 代码的产品的价格和每公斤价格。 我的代码:
barcodes = ['5449000000996']
for barcode in barcodes:
url = 'https://www.carrefour.es/?q=' + barcode
html = requests.get(url).content
bs = BeautifulSoup(html, 'lxml')
searchingprice = bs.find_all('strong', {'class':'ebx-result-price__value'})
print(searchingprice)
searchingpricerperkg = bs.find_all('span', {'class':'ebx-result__quantity ebx-result-quantity'})
print(searchingpricerperkg)
但我根本没有得到任何结果
这是 HTML 代码的截图:
我做错了什么?我尝试了其他网站,它似乎可以工作
【问题讨论】:
标签: html python-3.x web-scraping beautifulsoup request