実現したいこと
AWSのlambdaでSeleniumを使用してスクレイピングしたい
前提
Seleniumでのスクレイピングを定期実行したいと思い
https://zenn.dev/eito_blog/articles/72f7b459e2d591
上記のサイトのままheadlessChromeとseleniumをレイヤーにして
サイトにあるテストコードを入力しました。
メモリやタイムアウトも変更しています。
発生している問題・エラーメッセージ
リスポンスに
"errorMessage": "Unable to import module 'lambda_function': urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.0.2k-fips 26 Jan 2017. See: https://github.com/urllib3/urllib3/issues/2168",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
と出ます。
Seleniumでスクレイピングしようとしているのですがなぜurllibで引っ掛かるのでしょうか
該当のソースコード
python3.7
from selenium import webdriver
def lambda_handler(event, context):
URL = "https://news.yahoo.co.jp/"
options = webdriver.ChromeOptions() options.add_argument("--headless") options.add_argument("--disable-gpu") options.add_argument("--hide-scrollbars") options.add_argument("--single-process") options.add_argument("--ignore-certificate-errors") options.add_argument("--window-size=880x996") options.add_argument("--no-sandbox") options.add_argument("--homedir=/tmp") options.binary_location = "/opt/headless/python/bin/headless-chromium" #ブラウザの定義 browser = webdriver.Chrome( "/opt/headless/python/bin/chromedriver", options=options ) browser.get(URL) title = browser.title browser.close() return title
試したこと
python3.9や3.10ならいけると思いましたがダメでした
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。

回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。