質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Chrome

Google Chromeは携帯、テレビ、デスクトップなどの様々なプラットフォームで利用できるウェブブラウザです。Googleが開発したもので、Blink (レンダリングエンジン) とアプリケーションフレームワークを使用しています。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

selenium

Selenium(セレニウム)は、ブラウザをプログラムで作動させるフレームワークです。この原理を使うことにより、ブラウザのユーザーテストなどを自動化にすることができます。

Q&A

0回答

1019閲覧

Python+selenium+chromeが動かない

funash

総合スコア0

Chrome

Google Chromeは携帯、テレビ、デスクトップなどの様々なプラットフォームで利用できるウェブブラウザです。Googleが開発したもので、Blink (レンダリングエンジン) とアプリケーションフレームワークを使用しています。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

selenium

Selenium(セレニウム)は、ブラウザをプログラムで作動させるフレームワークです。この原理を使うことにより、ブラウザのユーザーテストなどを自動化にすることができます。

0グッド

0クリップ

投稿2022/06/29 01:06

編集2022/06/29 01:39

python+seleniumでwebスクレイピングをしています。

これまで問題なく利用できていたのですが、
Chromeのバージョンアップにより、エラーが発生するようになりました。

Chromeのバージョン:103.0.5060.66(Official Build) (64 ビット)
Python:3.10
selenium:4.3.0
ChromeDriver:version for 103.0.5060 google-chrome

上記の条件で以下のコードを実行したところ、

from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.chrome.options import Options from webdriver_manager.chrome import ChromeDriverManager import PySimpleGUI as sg def main(): # ウインドウの作成 sg.theme('LightGrey3') layout = [ [sg.Text('')], [sg.Button('スタート', size=(17, 2), key='-OK1-')] ] # セクション 2 - ウィンドウの生成 window = sg.Window('スクレイピング', layout, finalize=True, resizable=True) # セクション 3 - イベントループ while True: event, values = window.read() if event in [None, 'Cancel']: break else: url = "https://fishhook-line.com/" if event == '-OK1-': # seleniumのセットアップ options1 = webdriver.ChromeOptions() # 現在使っているプロファイルへのパス (chrome://version/ を開いて「プロフィール パス」から確認できます) options1.add_argument( '--user-agent=Mozilla/5.0 (Android 10; Mobile; rv:89.0) Gecko/89.0 Firefox/89.0') options1.add_argument( "user-data-dir=/Users/***/Library/Application Support/Google/Chrome21") driver1 = webdriver.Chrome( ChromeDriverManager().install(), chrome_options=options1) driver1.maximize_window() # driver = webdriver.Chrome( # executable_path="c:/driver/chromedriver.exe", chrome_options=options) driver1.get(url) WebDriverWait(driver1, 5) continue main()

以下のようなエラーが発生します。

[WDM] - ====== WebDriver manager ====== [WDM] - Current google-chrome version is 103.0.5060 [WDM] - Get LATEST chromedriver version for 103.0.5060 google-chrome [WDM] - Driver [C:\Users\funas\.wdm\drivers\chromedriver\win32\103.0.5060.53\chromedriver.exe] found in cache C:\Users\***\Desktop\test.py:44: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver1 = webdriver.Chrome( C:\Users\***\Desktop\test.py:44: DeprecationWarning: use options instead of chrome_options driver1 = webdriver.Chrome( DevTools listening on ws://127.0.0.1:60829/devtools/browser/c2eda952-770a-4ec2-8a87-b0fc08409eea Traceback (most recent call last): File "C:\Users\***\Desktop\test.py", line 53, in <module> main() File "C:\Users\***\Desktop\test.py", line 50, in main driver1.get(url) File "C:\Users\***\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 447, in get self.execute(Command.GET, {'url': url}) File "C:\Users\***\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 435, in execute self.error_handler.check_response(response) File "C:\Users\***\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot determine loading status from unknown error: unexpected command response (Session info: chrome=103.0.5060.66) Stacktrace: Backtrace: Ordinal0 [0x004E6463+2188387] Ordinal0 [0x0047E461+1762401] Ordinal0 [0x00393D78+802168] Ordinal0 [0x00387210+750096] Ordinal0 [0x0038675A+747354] Ordinal0 [0x00385D3F+744767] Ordinal0 [0x00384C28+740392] Ordinal0 [0x00385228+741928] Ordinal0 [0x0038EF2F+782127] Ordinal0 [0x00399FBB+827323] Ordinal0 [0x0039D310+840464] Ordinal0 [0x003854F6+742646] Ordinal0 [0x00399BF3+826355] Ordinal0 [0x003ECF6D+1167213] Ordinal0 [0x003DC5F6+1099254] Ordinal0 [0x003B6BE0+945120] Ordinal0 [0x003B7AD6+948950] GetHandleVerifier [0x007871F2+2712546] GetHandleVerifier [0x0077886D+2652765] GetHandleVerifier [0x0057002A+520730] GetHandleVerifier [0x0056EE06+516086] Ordinal0 [0x0048468B+1787531] Ordinal0 [0x00488E88+1805960] Ordinal0 [0x00488F75+1806197] Ordinal0 [0x00491DF1+1842673] BaseThreadInitThunk [0x75BD6739+25] RtlGetFullPathName_UEx [0x77E88FEF+1215] RtlGetFullPathName_UEx [0x77E88FBD+1165]

以前はpython3.9で実行していたのですが、
今回の不具合に伴い、アンインストール後、3.10を再インストールしています。

原因がわかる方、よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shskfjh

2022/07/02 06:24

似たようなエラーを僕もついさっき出しました。 seleniumのバージョンを4.2に下げるとうまく動くようになったので試してみてくださいー pip install selenium==4.2 詳しい原因は知らないですけど、バージョンアップによっての互換性の問題ですかね
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問