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を再インストールしています。
原因がわかる方、よろしくお願いします。
あなたの回答
tips
プレビュー