2017-08-05 56 views
1

我可以驅動一個無頭瀏覽器使用硒和鉻金絲雀。 但我無法使用分裂工作。Splnter selenium與Chrome加那利無頭(Python)

在此先感謝。

這是有用的。

import os 
from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.chrome.options import Options 

chrome_options = Options() 
chrome_options.add_argument("--headless") 
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary' 
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', chrome_options=chrome_options) 

這裏是行不通:

from splinter import Browser 
executable_path = {'executable_path':'/Applications/Google Chrome Canary/Contents/MacOS/Google Chrome Canary'} 
B=Browser('chrome',**executable_path) 

順便分裂不工作與phantomjs

executable_path = {'executable_path':'/Applications/phantomjs/bin/phantomjs'} 
B=Browser('phantomjs',**executable_path) 

的錯誤消息是

WebDriverException:消息:「谷歌Chrome Canary的可執行文件需要處於PATH。請參閱https://sites.google.com/a/chromium.org/chromedriver/home

這裏的路徑,通過os.os.environ['PATH']

/Users/jonschull-MBPR/miniconda2/bin:/Applications/Google Chrome Canary/Contents/MacOS/Google Chrome Canary:/Users/jonschull-MBPR/miniconda2/bin:/Users/jonschull-MBPR/anaconda/bin:/Users/jonschull-MBPR/Downloads/google-cloud-sdk/bin:/opt/local/bin:/opt/local/sbin:/Users/jonschull-MBPR/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/chromedrive:/opt/X11/bin:/usr/local/mongodb/bin 

感知並順便說一下,我試圖逃離 「谷歌\鍍鉻\金絲雀」

+0

歡迎使用Stack Overflow,請將您的解決方案作爲答案添加,而不是編輯您的帖子。 –

回答