Me tope con un script util en este hilo
https://hispafiles.ru/ac/res/164369.html#164988
e hice todo a pie pero el script no me quiere funcionar.
Corro el script
from os import listdir
from os.path import isfile,join
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
mypath = 'C:\\Users\\xxx\\Downloads\\cosplay' #acá va la dirección del folder con las imágenes que quieres subir (si tu folder tiene la forma C:\carpeta... tienes que duplicar los '\')
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
driver = webdriver.Chrome()
driver.maximize_window()
hilo = '
https://www.hispachan.org/ac/res/216877.html' #acá va la dirección del hilo en el cual quieres hacer el dump
for filename in onlyfiles:
ubicacion=mypath+'\\'+filename
print (ubicacion)
driver.get(hilo)
element=driver.find_element(By.XPATH,'//*[@id="postform"]/table/tbody/tr[3]/td[2]/input')
element.send_keys(ubicacion)
element=driver.find_element(By.XPATH,'//*[@id="postform"]/table/tbody/tr[1]/td[2]/input').click()
print ('enviando una imagen')
time.sleep(20)
y me sale esto
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
= RESTART: C:\Users\xxx\AppData\Local\Programs\Python\Python310\dumper de imagenes.py
C:\Users\xxx\Downloads\cosplay\1647728382339.jpg
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\dumper de imagenes.py", line 17, in <module>
element=driver.find_element(By.XPATH,'//*[@id="postform"]/table/tbody/tr[3]/td[2]/input')
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1251, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute
self.error_handler.check_response(response)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="postform"]/table/tbody/tr[3]/td[2]/input"}
(Session info: chrome=101.0.4951.64)
Stacktrace:
Backtrace:
Ordinal0 [0x0160B8F3+2406643]
Ordinal0 [0x0159AF31+1945393]
Ordinal0 [0x0148C748+837448]
Ordinal0 [0x014B92E0+1020640]
Ordinal0 [0x014B957B+1021307]
Ordinal0 [0x014E6372+1205106]
Ordinal0 [0x014D42C4+1131204]
Ordinal0 [0x014E4682+1197698]
Ordinal0 [0x014D4096+1130646]
Ordinal0 [0x014AE636+976438]
Ordinal0 [0x014AF546+980294]
GetHandleVerifier [0x01879612+2498066]
GetHandleVerifier [0x0186C920+2445600]
GetHandleVerifier [0x016A4F2A+579370]
GetHandleVerifier [0x016A3D36+574774]
Ordinal0 [0x015A1C0B+1973259]
Ordinal0 [0x015A6688+1992328]
Ordinal0 [0x015A6775+1992565]
Ordinal0 [0x015AF8D1+2029777]
BaseThreadInitThunk [0x76B96A14+36]
RtlInitializeExceptionChain [0x77A6A9FF+143]
RtlInitializeExceptionChain [0x77A6A9CA+90]
Que estoy haciendo mal?