每次尝试时,我都会在find_元素的指令中出错,有人可以尝试将图像上载到这个特定的网站:https://www.custojusto.pt/ai/form/0 告诉我怎么解决这个问题?在
def upload():
driver.get('https://www.custojusto.pt/ai/form/0')
#time.sleep(10)
driver.find_element_by_name('image').send_keys("https://images-na.ssl-images-amazon.com/images/I/41pzTMUV7AL._SY300_.jpg")
if __name__ == '__main__':
upload()
首先你可以用我相信的网址上传图片。你需要手动下载然后上传。您可以使用下面线程中讨论的方法下载图像
How to download image using requests
你的上传部分也在IFrame中,所以你需要先切换到IFrame
我测试了上面的代码,它对我很有用。注意一旦上传了图片,如果你需要上传另一张图片,再次使用
driver.switch_to.frame("image-upload")
,因为一个新的框架被创建了,旧的不再有效。在相关问题 更多 >
编程相关推荐