天天看點

Python + Splinter 實作自動化登入第一步中遇到的問題

在這裡隻是一些遇到的問題,在此備注一下,

Python 與 Splinter 的安裝過程就省略了。
  • chromedriver解決辦法:
import splinter.browser import Browser
b = Browser('chrome') #預設是Firefox
b.visit('http:\\www.baidu.com')
           

#基礎使用splinter的代碼,可能會遇到以下的錯誤:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build\bdist.win32\egg\splinter\browser.py", line 63, in Browser
  File "build\bdist.win32\egg\splinter\driver\webdriver\chrome.py", line 34, in __init__
  File "C:\Python27\lib\site-packages\selenium-3.5.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Python27\lib\site-packages\selenium-3.5.0-py2.7.egg\selenium\webdriver\common\service.py", line 81, in start
    os.path.basename(self.path), self.start_error_message)
####selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home 
           

解決辦法: 把下載下傳好的chromedriver.exe 放到Python的安裝目錄下即可解決這個問題,試了一下Path删掉莫得發現什麼問題。(咱手機先這樣,後續問題接着寫。)