• Home
  • Uncategorized
  • Scrape web with selenium and chromedriver with python, on Ubuntu 17.10

Scrape web with selenium and chromedriver with python, on Ubuntu 17.10

First download chromedriver:

Eg: Downloading latest version ChromeDriver 2.37:

cd ~/Downloads
wget https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo cp ~/Downloads/chromedriver /usr/local/share/
sudo chmod +x /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver

Now install selenium:

pip install selenium

Python test script:

from selenium import webdriver
import os
chromedriver = "/usr/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
my_url = 'https://www.pastest.com/'
driver.get(my_url)
driver.quit()

Joel G Mathew

Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an Android and Linux enthusiast. His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets. When away from the tech world, Joel is a practising ENT Surgeon.

Leave a Reply

Your email address will not be published. Required fields are marked *