问题描述:

I'd like to input files from a folder into a website. I was able to input one file but I want to input a file from a folder, run the online job, then input another file from the same folder until all the jobs are submitted. Here's my code for one file input.

from selenium import webdriver

url = "http://www.example.com"

email = "[email protected]"

data = open ("file.txt","r").read()

title = data[16:22].replace("|","")

driver = webdriver.Chrome(executable_path='path_to/chromedriver.exe')

driver.get(url)

emailid = driver.find_element_by_name("email_address")

emailid.send_keys(email)

job = driver.find_element_by_name("job_title")

job.send_keys(title)

submit = driver.find_element_by_name("protein_sequence")

submit.send_keys(data)

driver.find_element_by_class_name("input_button").click()

print submit.page_source

Thank you.

网友答案:

You can try using mechanize, something like this br.back() and repeat the process.

相关阅读:
Top