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

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

新規登録して質問してみよう
ただいま回答率
85.48%
スクレイピング

スクレイピングとは、公開されているWebサイトからページ内の情報を抽出する技術です。

Python

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

Q&A

解決済

1回答

2588閲覧

SeleniumによるGoogle mapsのデータスクレイピングによるエラーメッセージの解消

Rf_i.m

総合スコア6

スクレイピング

スクレイピングとは、公開されているWebサイトからページ内の情報を抽出する技術です。

Python

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

0グッド

0クリップ

投稿2020/03/26 08:50

前提・実現したいこと

https://su-gi-rx.com/archives/3217
以上のURLに従いながら、SeleniumによるGoogle mapsのデータをスクレイピングをしています。
上のURLに掲載されているものを参考にJupiter Notebookに入力し、検索ワードに「渋谷」と入力したところ、以下のようなエラーメッセージが出ました。

発生している問題・エラーメッセージ

検索キーワード:渋谷 --------------------------------------------------------------------------- SessionNotCreatedException Traceback (most recent call last) <ipython-input-14-95aa54cb1174> in <module> 10 keys = input("検索キーワード:") 11 #Google Chromeのドライバを用意 ---> 12 driver = webdriver.Chrome() 13 14 #Google mapsを開く ~\Anaconda3\envs\kerastutorial\lib\site-packages\selenium\webdriver\chrome\webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive) 79 remote_server_addr=self.service.service_url, 80 keep_alive=keep_alive), ---> 81 desired_capabilities=desired_capabilities) 82 except Exception: 83 self.quit() ~\Anaconda3\envs\kerastutorial\lib\site-packages\selenium\webdriver\remote\webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options) 155 warnings.warn("Please use FirefoxOptions to set browser profile", 156 DeprecationWarning, stacklevel=2) --> 157 self.start_session(capabilities, browser_profile) 158 self._switch_to = SwitchTo(self) 159 self._mobile = Mobile(self) ~\Anaconda3\envs\kerastutorial\lib\site-packages\selenium\webdriver\remote\webdriver.py in start_session(self, capabilities, browser_profile) 250 parameters = {"capabilities": w3c_caps, 251 "desiredCapabilities": capabilities} --> 252 response = self.execute(Command.NEW_SESSION, parameters) 253 if 'sessionId' not in response: 254 response = response['value'] ~\Anaconda3\envs\kerastutorial\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params) 319 response = self.command_executor.execute(driver_command, params) 320 if response: --> 321 self.error_handler.check_response(response) 322 response['value'] = self._unwrap_value( 323 response.get('value', None)) ~\Anaconda3\envs\kerastutorial\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response) 240 alert_text = value['alert'].get('text') 241 raise exception_class(message, screen, stacktrace, alert_text) --> 242 raise exception_class(message, screen, stacktrace) 243 244 def _value_or_default(self, obj, key, default): SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81

該当のソースコード

Python

1pip install chromedriver-binary 2#seleniumとbeautifulsoupをインポート 3import chromedriver_binary 4from selenium import webdriver 5import time 6from bs4 import BeautifulSoup 7import requests 8import bs4 9 10#検索蘭にキーワードを記入 11keys = input("検索キーワード:") 12#Google Chromeのドライバを用意 13driver = webdriver.Chrome() 14 15#Google mapsを開く 16url = 'https://www.google.co.jp/maps/' 17driver.get(url) 18 19time.sleep(5) 20 21#データ入力 22id = driver.find_element_by_id("searchboxinput") 23id.send_keys(keys) 24 25time.sleep(1) 26 27#クリック 28search_button = driver.find_element_by_xpath("//*[@id='searchbox-searchbutton']") 29search_button.click() 30 31time.sleep(3) 32 33login_button = driver.find_element_by_class_name("section-result-title") 34login_button.click() 35 36time.sleep(3) 37 38page_source = driver.page_source 39soup = BeautifulSoup(page_source, 'html.parser') 40 41title = soup.find(class_="GLOBAL__gm2-headline-5 section-hero-header-title-title") 42link = soup.find_all(class_="section-info-text") 43 44 45print("-------------------------------") 46print(title.text.strip()) 47print(link[0].text.strip()) 48print(link[2].text.strip()) 49print(link[3].text.strip()) 50print("-------------------------------")

試したこと

・コマンドプロンプトに同様の内容を入力して実行しましたが、エラーが出ました。

補足情報(FW/ツールのバージョンなど)

・Python3はAnacondaパッケージでインストールしました。

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

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

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

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

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

meg_

2020/03/26 10:43

googleはスクレイピング禁止だったと思いますが、許可を取られているのでしょうか?
Rf_i.m

2020/03/26 12:30

meg_さん ご提言ありがとうございます。 規約自体は確認しており、今後スクレイピングは実施しないです。 エラー文の意味を理解しかねたので、今後別サイトでスクレイピングを行なう機会のために、質問させていただきました。 貴重なお時間の中でこのようにご助言いただきありがとうございます。 また、誤解を招く質問文、題名になってしまい大変申し訳ございません。
guest

回答1

0

ベストアンサー

エラーメッセージの、

This version of ChromeDriver only supports Chrome version 81

が回答です。

投稿2020/03/26 12:57

otn

総合スコア84557

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

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

Rf_i.m

2020/03/26 13:03

otn さんありがとうございます。 ブラウザとドライバーの整合性がなかったのですね。 次回別サイトでスクレイピングする際に参考に致します。ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問