嘿,我似乎无法从这个网站上抓取图片
https://www.nike.com/gb/w/new-mens-shoes-3n82yznik1zy7ok
我正在使用以下代码
product.find('img', {'class': 'css-1fxh5tw product-card__hero-image'})['src']]
它返回这个
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
答案 0 :(得分:1)
你的代码没有错。我已经提取了图像
import requests
from bs4 import BeautifulSoup
url ="https://www.nike.com/gb/w/new-mens-shoes-3n82yznik1zy7ok"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
images = soup.find_all('img', {'class':'css-1fxh5tw product-card__hero-image'},src=True)
for i in images:
if 'data:image' not in i['src']:
print(i['src'])