test_yahoo.py 753 B

1234567891011121314151617181920212223242526
  1. import sys
  2. import time
  3. sys.path.insert(0,'./web')
  4. import browser_common
  5. from selenium import webdriver
  6. from selenium.webdriver.common.keys import Keys
  7. from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
  8. jb=browser_common.JBrowser()
  9. #jb.set_profile_path('Profile 7')
  10. jb.set_profile_path(None)
  11. #jb.get('https://www.similarweb.com/website/yahoo.com/')
  12. #jb.get('https://www.similarweb.com/website/ptt.cc/')
  13. #jb.get('https://www.similarweb.com/website/591.com.tw/')
  14. #jb.get('https://data.similarweb.com/api/v1/data?domain=591.com.tw')
  15. driver=jb.get_driver()
  16. jb.get('https://tw.yahoo.com/?p=us')
  17. time.sleep(3)
  18. elmts=driver.find_elements_by_xpath('//*[@id="panel4-content"]/div/ul/li')
  19. print(elmts)
  20. for elmt in elmts:
  21. print(elmt.text)