実現したいこと
AWS EC2上でseleniumを使い、firefoxでスクレイピングをしたい。
前提
AWSのEC2でseleniumを使ったスクレイピングツールの開発をしています。
geckodriverを用いて、firefoxの起動が出来ません。
そもそもAWS EC2ではgekcodriverでfirefoxを起動できないのでしょうか?
別途、おすすめのデプロイ先がありましたら、ご教示いただけますと幸いです。
発生している問題・エラーメッセージ
Python
1selenium.common.exceptions.SessionNotCreatedException: 2Message: Expected browser binary location, 3but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
該当のソースコード
Python
1async def submit_form(request: Request, url: str = Form(...), number: int = Form(...),suburl: str = Form(...)): 2 logger.debug("Starting form submission") 3 for _ in range(number): 4 options = Options() 5 options.add_argument('--headless') 6 options.binary = FirefoxBinary('/usr/bin/firefox') 7 driver = webdriver.Firefox(executable_path='/home/ubuntu/selenium/geckodriver', options=options) 8 driver.get("https://www.google.co.jp/") 9 search = driver.find_element(By.NAME, "q")
試したこと
・whichi firefoxでバイナリファイルの位置確認済み。(/usr/bin/firefox)
・FirefoxBinaryの指定を「'/usr/bin/firefox/firefox113」にする
補足情報(FW/ツールのバージョンなど)
・firefox-113
・AWS EC2のOSはUbuntu
・geckodriverはfirefox113に対応するものを入れています。
ここにより詳細な情報を記載してください。
