无法使用python获取jpg图像 [英] unable to get jpg image using python

查看:84
本文介绍了无法使用python获取jpg图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我只想提取jpg链接,但它会打印

解决方案

使用 images ['src'] 打印属性.

As i want to extract jpg links only but it print whole links from 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)

解决方案

Use images['src'] to print out the attribute.

这篇关于无法使用python获取jpg图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆