利用selenium实现中国知网的注册(纪念自己的第一个Paco程序)

import time
from selenium import webdriver

browser = webdriver.Chrome()
url = 'http://my.cnki.net/elibregister/commonRegister.aspx'
browser.get(url)
cookies = browser.get_cookies()
cookies2 = cookies[2]['value']
input = browser.find_element_by_id('username')
input.send_keys("sdadasdfsafdg")
time.sleep(1)
input2 = browser.find_element_by_id('txtPassword')
input2.send_keys('iPadsdadsa')
input3 = browser.find_element_by_id('txtEmail')
input3.send_keys('[email protected]')
input4 = browser.find_element_by_id('txtOldCheckCode')
input4.send_keys(cookies2)
button = browser.find_element_by_class_name('btn')
button.click()
time.sleep(5)
browser.close()
                                                        ---by Thomas

你可能感兴趣的:(利用selenium实现中国知网的注册(纪念自己的第一个Paco程序))