前提・実現したいこと
seleniumを利用したスクレイピングを行なっています。
最初に簡単な動作確認をしたところ「geckodriverがない」旨のエラーが2つ出て実行できません。
確認した点は「試したこと」に記載しています。
発生している問題・エラーメッセージ
Traceback (most recent call last): 〜中略〜 raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver' ←エラー1 During handling of the above exception, another exception occurred: Traceback (most recent call last): 〜中略〜 selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. ←エラー2
該当のソースコード
python
1from selenium import webdriver 2 3browser = webdriver.Firefox() 4browser.get = ('https://toyokeizai.net/list/welcome') 5
試したこと
●エラー2への対応
①PATHの確認
echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
②PATHの場所にgeckodriverがあることの確認
/usr/local/binにて目視で確認。
③対象のgeckodriverが最新であることの確認
/usr/local/bin/geckodriver --version
geckodriver 0.20.1 The source code of this program is available from testing/geckodriver in https://hg.mozilla.org/mozilla-central. This program is subject to the terms of the Mozilla Public License 2.0. You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.
●エラー1への対応
④webdriver.Firefoxの引数にPATHを設定
下記のサイトを参考にコードを書き換え。しかし結果は変わらず。。
https://qiita.com/FGtatsuro/items/35adcc1e5c1dfbc75c6f
補足情報(FW/ツールのバージョンなど)
mac OS High Sierra 10.13.4
Python 3.6.3 :: Anaconda, Inc.

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。