1

I'm browsing through a website using dryscrape in python and i need to upload a file to this site. But there is only one way of doing it, that is clicking in a button and browse into my files and select the one i want. How can i do it with python? i would appreciate if someone could help me using dryscrape too, but i'm accepting all answers.

heres the example image: IMG

nahzor
  • 460
  • 1
  • 4
  • 20

2 Answers2

0

You can use Selenium. I tested this code and it works.

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()

Resources

Miguel Mota
  • 20,135
  • 5
  • 45
  • 64
0

For those who are searching for the answer in dryscrape i translated the selenium code to dryscrape:

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")

just as simple as it is.