I've been stuck on a task for a few days. I can't load images automatically on the vinted image browser. I tried running the following code:
from os import listdir
from os.path import isfile, join
from time import sleep
from pyautogui import press, write
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
def get_images(directory_path) -> str:
images: str = ""
f: str
image_name: str
for filename in listdir(directory_path):
f = join(directory_path, filename)
if isfile(f):
image_name = f.replace(f"{directory_path}\\", "")
images += f'\"{image_name}\" '
return directory_path + "\\" + images
option: Options = Options()
option.add_experimental_option("debuggerAddress", "localhost:8989")
driver: Chrome = Chrome(service=Service(ChromeDriverManager().install()),
options=option)
mode: str = By.CSS_SELECTOR
driver.maximize_window()
driver.get("https://www.vinted.it/items/new")
# * images
sleep(1)
driver.find_element(mode, "#photos > div.Cell_cell__3V4ao.Cell_wide__1ukxw > div > div > div > div.media-select__input > div > button").click()
sleep(1)
directory_path: str = r"C:\Users\Memmo\Pictures\Camera Roll"
write(get_images(directory_path))
press('enter')
The problem is that the paths of the recovered images end up on the terminal where the script is run, while they should be set in the upload window. It almost seems that the focus is lost.
I could also set the html of the image on the upload section but it seems a more complicated, expensive and risky way than the one already undertaken.
If someone has already faced "more custom" image browsers compared to the classic ones, I would be curious to know how solved this problem.
Thanks in advance.
from Automatically upload images on vinted
No comments:
Post a Comment