1

我正在使用 python 中的 dryscrape 浏览网站,我需要将文件上传到该网站。但是只有一种方法可以做到这一点,即单击一个按钮并浏览我的文件并选择我想要的那个。我怎么能用python做到这一点?如果有人也可以帮助我使用dryscrape,我将不胜感激,但我接受所有答案。

继承人的示例图像: IMG

4

2 回答 2

0

您可以使用。我测试了这段代码,它可以工作。

from selenium import webdriver

url = "https://example.com/"

driver = webdriver.Chrome("./chromedriver")
driver.get(url)

input_element = driver.find_element_by_css_selector("input[type=\"file\"]")

# absolute path to file
abs_file_path = "/Users/foo/Downloads/bar.png"
input_element.send_keys(abs_file_path)

sleep(5)

driver.quit()

资源

于 2017-06-22T02:51:31.313 回答
0

对于那些在干刮中寻找答案的人,我将硒代码翻译为干刮:

element = sessin.at_xpath("xpath...") # Session is a dryscrape session
# The xpath is from the button like the one in the image "Browse..."
element.set("fullpath")

就这么简单。

于 2017-06-22T15:12:42.937 回答