I tried to make a prada site photo download program. But other sites are not compatible

Viewed 23
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import Select
import requests 

def saveimg(url,index,count):
    print(url,index,count)
    img_data = requests.get(url).content 
    with open(f'{index}/{count}.jpg', 'wb') as handler: 
    handler.write(img_data) 

chromepath="C:\\Users\\shtre\\Desktop\\json\\chromedriver.exe"
driver = webdriver.Chrome(service=Service(chromepath))
driver.maximize_window()

def getimg(index,url):
    
xpath='//[@id="page"]/div[4]/div/div[1]/div[4]/div[1]/section/div/div/div/div/div[2]/picture/img'

    try:
        driver.get(url)
    except:
        return

    path = f'./{index}'
    if(not os.path.exists(path)):
        os.mkdir(path)

    
    while True:
        try:
            mainimg = driver.find_element(By.XPATH ,xpath)
            mainimg.click()
            break
        except:
            continue

    count=0
    imglist=[]
    for picture in driver.find_elements(By.TAG_NAME,"picture")[1:]:
        img=picture.find_element(By.TAG_NAME,"img")
        imgurl=img.get_attribute("src")
        if(not imgurl in imglist):
            imglist.append(imgurl)
            count+=1
            saveimg(imgurl,index,count)


urllist=['https://www.gucci.com/de/de/pr/women/handbags/crossbody-bags-for-women/mini-top-handle-bag-with-double-g-p-715771AAA0O9746']

for index,url in enumerate(urllist):
    getimg(index+2,url)

driver.close()

made a program to download prada pictures with selenium.

And I tested it to see if it's compatible with Gucci. requests.exceptions.MissingSchema: Invalid URL 'None': No scheme supplied. Perhaps you meant http://None? An error appears.

Do I need to make various changes to make other sites compatible? I have pasted the http:// that appears in the error in several places, but it doesn't work.

I paid someone else to make it., but I can't edit it because I don't understand the code parts correctly.

If this question is not suitable for the site, please let me know and I will remove it immediately.

I asked the question in translation, so the content may not be smooth. sorry.

error : MissingSchema Invalid URL 'None': No scheme supplied. Perhaps you meant None? File "C:\coding\brand_image_down copy.py", line 10, in saveimg img_data = requests.get(url).content File "C:\coding\brand_image_down copy.py", line 47, in getimg saveimg(imgurl,index,count) File "C:\coding\brand_image_down copy.py", line 53, in getimg(index+2,url)

0 Answers
Related