selenium でFirefoxをヘッドレスで使いたいが、うまくいきません。
原因と対策をご教示いただければ幸いです。
<実現したいこと>
指定したurlのhtmlを取得したい
<エラー内容>
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities
<コード内容>
python
1from selenium import webdriver 2from selenium.webdriver.firefox.options import Options 3 4# ブラウザーを起動 5options = Options() 6options.binary_location = '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox' 7options.add_argument('-headless') 8driver = webdriver.Firefox(firefox_options=options) 9 10# Google検索画面にアクセス 11driver.get('https://www.google.co.jp/') 12 13# htmlを取得・表示 14html = driver.page_source 15print(html) 16 17# ブラウザーを終了 18driver.quit()
回答1件
あなたの回答
tips
プレビュー