python - 无法使用python获取jpg图像
问题描述
因为我只想提取 jpg 链接,但它从https://www.skechers.com/women/shoes/athletic-sneakers/?start=0&sz=168打印整个链接
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import pandas as pd
import time
url = 'https://www.skechers.com/women/shoes/athletic-sneakers/?start=0&sz=168'
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ['enable-automation'])
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36")
options.add_argument("--remote-debugging-port=9222")
driver = webdriver.Chrome('D:/chromedriver',options=options)
driver.get(url)
time.sleep(30)
pageSource = driver.page_source
soup = BeautifulSoup(pageSource, 'html.parser')
content= soup.find_all('div',class_='col-6 col-sm-4 col-xl-3 mb-2 mb-md-1 mb-lg-4 px-lg-3')
for item in content:
try:
images = item.find('img',{'class':'tile-image c-product-tile__img'},src=True)
except:
images=''
print(images)
解决方案
用于images['src']
打印出属性。
推荐阅读
- python - Python 3 升级
- java - Vaadin 中按钮的多行字幕不起作用
- javascript - Firebase 功能运行速度极慢
- c++ - 使用静态成员时有关 C++ 中内存分配的问题
- kotlin - Kotlin 扫描器 - 验证 nextLine() 用户输入
- c++ - 如何检查 char 编码是否为 ASCII?
- c# - Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlOptionsExtension 类型中的方法“get_Info”没有实现
- node.js - 从 Rest API 中的 repo 获取数据
- sql - 在 Case 表达式中使用子查询
- html - 为什么我不能在 div 中设置离子按钮的样式