Raspberry pi3でseleniumを使うためにChromium, Chromedriverらへんのインストール


For forgetful me….

# My Pi3

```terminal
🐨$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 10 (buster)
Release:	10
Codename:	buster
```
```terminal
🐨$ uname -a
Linux raspberrypi 5.4.79-v7+ #1373 SMP Mon Nov 23 13:22:33 GMT 2020 armv7l GNU/Linux
```
# 大事なこと
`chromedriver`, `chromium-browser`, `chromium-codecs-ffmpeg-extra`, `chromium-chromedriver`のバージョンを合わせる｡

デフォルトで入っているChromiumのバージョンは`86.XXX.XX...`系だったが, 拾ってこれるdriverが`87.XXX.XX...`だったので怒られた｡

# やったこと
- `chromedriver`のinstall
- `chromium-browser`のupdate
    - `chromium-codecs-ffmpeg-extra`のupdate
- `chromium-chromedriver`のinstall

# 実行
## 使うファイルをダウンロード
```terminal

$ wget http://launchpadlibrarian.net/508931216/chromium-browser_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb
$ wget http://launchpadlibrarian.net/508931218/chromium-codecs-ffmpeg-extra_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb
$ wget http://launchpadlibrarian.net/507792522/chromium-chromedriver_87.0.4280.66-0ubuntu0.16.04.1_armhf.deb

$ ls
chromium-browser_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb
chromium-chromedriver_87.0.4280.88-0ubuntu0.18.04.1_armhf.deb
chromium-codecs-ffmpeg-extra_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb
```
## インストール
```terminal
$ sudo dpkg -i chromium-codecs-ffmpeg-extra_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb
(Reading database ... 99100 files and directories currently installed.)
Preparing to unpack chromium-codecs-ffmpeg-extra_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb ...
Unpacking chromium-codecs-ffmpeg-extra (87.0.4280.66-0ubuntu0.18.04.1) over (86.0.4240.197-rpt1) ...
Setting up chromium-codecs-ffmpeg-extra (87.0.4280.66-0ubuntu0.18.04.1) ...

$ sudo dpkg -i chromium-browser_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb
(Reading database ... 99097 files and directories currently installed.)
Preparing to unpack chromium-browser_87.0.4280.66-0ubuntu0.18.04.1_armhf.deb ...
Unpacking chromium-browser (87.0.4280.66-0ubuntu0.18.04.1) over (87.0.4280.66-0ubuntu0.18.04.1) ...
Setting up chromium-browser (87.0.4280.66-0ubuntu0.18.04.1) ...
update-alternatives: using /usr/bin/dillo to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
Processing triggers for gnome-menus (3.31.4-3) ...
Processing triggers for desktop-file-utils (0.23-4) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for man-db (2.8.5-2) ...

$ sudo dpkg -i chromium-chromedriver_87.0.4280.88-0ubuntu0.18.04.1_armhf.deb
Selecting previously unselected package chromium-chromedriver.
(Reading database ... 99097 files and directories currently installed.)
Preparing to unpack chromium-chromedriver_87.0.4280.88-0ubuntu0.18.04.1_armhf.deb ...
Unpacking chromium-chromedriver (87.0.4280.88-0ubuntu0.18.04.1) ...
Setting up chromium-chromedriver (87.0.4280.88-0ubuntu0.18.04.1) ...
```

## 確認
```terminal
$ chromedriver --version
ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761})

$ chromium-browser --version
Chromium 87.0.4280.66 Built on Ubuntu , running on Raspbian 10
```

# Seleniumが動くか試す
```terminal
pip install selenium
```

```python
from selenium import webdriver
chrome_option = webdriver.ChromeOptions()
chrome_option.add_argument('--headless')
driver = webdriver.Chrome(options=chrome_option)
driver.get("https://profile.yoshimoto.co.jp/talent/detail?id=6504")
driver.save_screenshot('screeeeeeeeeeenshot.png')
driver.quit()
```

ほい
![screeeeeeeeeeenshot.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/141196/3d6e6437-559d-e8fa-726b-3ccdd35b7792.png)

# 参考
- https://sun0range.com/information-technology/raspberry-pi-selenium
- https://note.com/sig_eng/n/ne135cfe37023