Advertisement
cwchen

Selenium simple demo

Jun 25th, 2016
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from selenium import webdriver
  2.  
  3. url = 'http://structurednotes-announce.tdcc.com.tw/Snoteanc/apps/bas/BAS210.jsp'
  4.  
  5. browser = webdriver.Firefox()
  6. browser.get(url)
  7.  
  8. agentSelect = browser.find_element_by_id('agent')
  9. for option in agentSelect.find_elements_by_tag_name('option'):
  10.     if option.text == "法商東方匯理銀行台北分行":
  11.         option.click()
  12.         break
  13.  
  14. dateSelect = browser.find_element_by_id('stopDate')
  15. for option in dateSelect.find_elements_by_tag_name('option'):
  16.     if option.text == '已到期':
  17.         option.click()
  18.         break
  19.  
  20. button = browser.find_element_by_xpath('//input[@type="button" and @value="查詢"]')
  21. button.click()
  22.  
  23. print(browser.page_source)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement