2
3

More than 3 years have passed since last update.

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

Posted at

For forgetful me….

My Pi3

🐨$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
🐨$ 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

実行

使うファイルをダウンロード


$ 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

インストール

$ 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) ...

確認

$ 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が動くか試す

pip install selenium
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

参考

2
3
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
2
3