Home > Back-end >  Selenium for Chromium in Python
Selenium for Chromium in Python

Time:05-16

I've created a Python script to collect data from different websites using Selenium. On my Windows PC the script works fine and does exactly what it's supose to do. Now I'm trying to make my script run on my Raspberyy Pi. On my PC I use Google Chrome with selenium but ofcourse Chrome is not supported on a Raspberry Pi. Instead I have to use Chromium but I struggle to make this work. I use the following code to start my driver:

import requests
from selenium import webdriver

session_requests = requests.session()
ser = Service(r"/home/pi/Downloads/chromedriver")
op = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=ser, options=op)

With this code I get the following error:

OSError: [Errno 8] Exec format error: '/home/pi/Downloads/chromedriver'

This error is because my chromedriver is for Google Chrome and not Chromium. When I look for the driver for Chromium, it automatically gives me the driver for Google Chrome instead.

I'm using Chromium version 98.0.4758.106. Is there a driver for Chromium or should I look for another solution? I found a work-around to download Google Chrome on my Raspberry Pi, but this does not look like it should be done. Any suggestions are appreciated, thanks in advance!

CodePudding user response:

After a long search I found a solution for my own problem. People from the Raspbian project have compiled chromium-chromedriver version for the armhf platform and added it to the repo. The following command line will add the Chromium-driver and make it ready to use:

sudo apt-get install chromium-chromedriver

With this solution you will no longer need to give the path to the driver.

Source: https://ivanderevianko.com/2020/01/selenium-chromedriver-for-raspberrypi

  • Related