Python3.4 splinter of simulates the use of filling out forms

  • 2020-12-09 00:56:34
  • OfStack

As shown below:


from splinter.browser import Browser

b = Browser('chrome')
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
b.visit(url) # Access to web sites 
first_found = b.find_by_id('login_user').click()
b.fill('loginUserDTO.user_name', '12306 account ')
b.fill('userDTO.password', '12306 password ') 
input()
sec_found = b.find_by_id('selectYuding').click()
b.cookies.add({'_jc_save_fromStation': '%u4E0A%u6D77%2CSHH'})
b.cookies.add({'_jc_save_toStation': '%u6D1B%u9633%2CLYF'})
b.cookies.add({'_jc_save_fromDate': '2017-02-17'})
b.cookies.add({'_jc_save_toDate': '2017-02-19'})
b.reload()
third_found = b.find_by_text(u' The query ').click()
b.find_by_text(u' booking ')[4].click()

Related articles: