【发布时间】:2020-03-20 19:42:58
【问题描述】:
我正在尝试使用 BeautifulSoup4 https://www.daraz.com.bd/products/awei-y336-portable-wireless-bluetooth-mini-speaker-charging-cable-i128428097-s1048302559.html?search=1 从该网站上抓取产品图库图片 url,但我找不到任何方法。有些产品有 3 张图片,有些产品有更多。
谁能告诉我如何使用 BeautifulSoup 抓取画廊图片的网址?
这是我的代码
from selenium import webdriver
from bs4 import BeautifulSoup
browser = webdriver.Chrome()
browser.get("https://www.daraz.com.bd/products/awei-y336-portable-wireless-bluetooth-mini-speaker-charging-cable-i128428097-s1048302559.html?search=1")
soup = BeautifulSoup(browser.page_source, "html.parser")
container = soup.find_all("body")
for items in container:
title = items.find("div",{"class":"pdp-product-title"}).text
price = items.find('span', attrs={'class':'pdp-price'}).text.strip(" ৳")
print(title,price)
browser.quit()
【问题讨论】:
-
你做了什么?这不是软件服务。
-
Juan 我已经构建了可以从该页面提取产品标题、描述和其他信息的代码,但我不知道如何在 beautifulsoup 上抓取产品图库图片 url,因此我将其发布在这里以获取帮助。我是刚开始学习代码的新手。
-
如果您不提供最小可重现示例,则很难提供帮助。这样人们就不必从零开始,他们可以重用你的代码。 stackoverflow.com/help/minimal-reproducible-example
-
请参阅How to Ask、help center。这至少是您关于抓取这个确切网站的第三个问题。 Stack Overflow 不是免费的代码编写服务,也不是提供个性化指南和教程。 请参阅:How to Ask、help center、meta.stackoverflow.com/questions/261592/…。
-
Juan Javier Santos Ochoa 我更新了我的帖子并添加了我的代码,请参阅
标签: python image image-processing web-scraping beautifulsoup