PhantomJS被selenium棄用了。。。所以只能找其他瀏覽器來代替


seleim 官方參考文檔

    http://selenium-python.readthedocs.io/index.html

首先下載文檔中說明的geckodriver
https://github.com/mozilla/geckodriver/releases
然后將geckodriver 放進/usr/bin 或者/usr/local/bin

 #coding:utf-8
  2 from selenium.webdriver import Firefox
  3 from selenium.webdriver.firefox.options import Options
  4 
  5 if __name__ == "__main__":
  6     options = Options()
  7     options.add_argument('-headless')  # 無頭參數
  8     driver = Firefox( firefox_options=options)
  9     driver.get('http://www.baidu.com')
 10     print(driver.page_source)
 11     driver.save_screenshot('baidu.png')
 12     driver.quit()


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM