0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows上でのWebスクレピング環境構築(Selenium)

Posted at

1. 本文の目的

Webスクレイピングの技術を勉強して、各種タスクを自動化してみたい。
Windows上でSeleniumを使用したWebスクレイピングの環境構築方法を記載する。

2. 方法

2-1 環境

OS : Windows10

2-2 Jupyter環境の準備

Jyupterをインストールします。インストール手順はこちら

インストール完了後、適当な場所にworkディレクトリ(例:C:/Users/xxxx/Desktop/work/)を作成する。Jupyterを起動し空のシートをworkingディレクトリに作成する。

2-3 geckodriverドライバーインストール

geckodriverの取得が必要です。こちらからwindows版をダウンロードします。
17.JPG

zipファイルを展開後、「geckodriver.exe」をworkディレクトリ(例:C:/Users/xxxx/Desktop/work/)に配置します。

2-4 chromedriverドライバーインストール

chromedriverの取得が必要です。まずは、PCにインストールされているchromeのversionを調べます。(ヘルプ → Google Chromeについて)

16.JPG

こちらよりお使いのchromeのversionに合致したChromeDriverをダウンロードしてください。ダウンロード後、中身を展開して、「chromedriver.exe」をworkディレクトリ(例:C:/Users/xxxx/Desktop/work/)に配置します。

18.JPG

3. 動作チェック

(1)pipをインストールする。

pip install selenium

(2)webブラウザを立ち上げ、yahooJapanのページを開く。

from selenium import webdriver
browser = webdriver.Chrome(executable_path="C:/Users/Takeshi/Desktop/work/chromedriver.exe")
browser.get('https://www.yahoo.co.jp')

実行環境のスクリーンショット
19.JPG

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?