Module summary that automates and assists WebDriver installation with Python

Module summary to help install WebDriver in Python

When scraping with Selenium etc., it may not work if the version of WebDriver is different, so I searched for a module that matches the version without permission and summarized it.

For chrome

chromedriver-autoinstaller

Installation method

pip install chromedriver-autoinstaller

How to use

Add to code that executes

from selenium import webdriver
import chromedriver_autoinstaller

chromedriver_autoinstaller.install()  

Description

Check if the correct version of chromedriver exists and if not, install the correct version

def install(cwd=False):
    """
    Appends the directory of the chromedriver binary file to PATH.
    :param cwd: Flag indicating whether to download to current working directory
    :return: The file path of chromedriver
    """
def get_chrome_version():
    """
    Get installed version of chrome on client
    :return: The version of chrome
    """

chromedriver-py It seems to automatically download and install the latest chromedriver binary version

Installation method

 pip install chromedriver-py

How to use

Adding from chromedriver_py import binary_path will assign the Chrome driver path to binary_path It seems that it will be automatically updated to the latest version

from selenium import webdriver
from chromedriver_py import binary_path # this will get you the path variable

driver = webdriver.Chrome(executable_path=binary_path)

driver.get("http://www.python.org")
assert "Python" in driver.title

ChromeDriver Installer for Python Omitted because it seems difficult to read something

Installation

pip install chromedriver_installer \
    --install-option="--chromedriver-version=2.10"

The function to install the driver and pass the path like this Simple


Firefox geckodriver-autoinstaller A script that automatically installs geckodriver

Installation

pip install geckodriver-autoinstaller

How to use

Add ```import geckodriver_autoinstallerto the code you want to use and geckodriver_autoinstaller.install () `` Add

from selenium import webdriver
import geckodriver_autoinstaller

geckodriver_autoinstaller.install() 
# Check if the current version of geckodriver exists
# and if it doesn't exist, download it automatically,
# then add geckodriver to path
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title

Description

Check if the correct version of geckodriver exists and if not, install the correct version

def install(cwd=False):
    """
    Appends the directory of the geckodriver binary file to PATH.
    :param cwd: Flag indicating whether to download to current working directory
    :return: The file path of geckodriver
    """
def get_firefox_version():
    """
    Get installed version of chrome on client
    :return: The version of chrome
    """

pygeckodriver A script that automatically checks every hour for updates to the gecko driver and installs it

Installation

pip install pygeckodriver

How to use

If you add pygeckodriver import geckodriver_path, the path of geckodriver will be entered in geckodriver_path.

from selenium import webdriver
from pygeckodriver import geckodriver_path

bs = webdriver.Firefox(executable_path=geckodriver_path)
bs.get('https://www.pypi.org')

Comprehensive

Pyderman

Installation

 pip install pyderman

How to use (Firefox)

import pyderman as driver
#Install FIrefox driver
path = driver.install(browser=driver.firefox)
print('The path of the installed geckodriver driver is: %s' % path)

Description

Downloads the driver for the specified browser and returns the destination path

def install(browser=None, file_directory='./lib/', verbose=True, chmod=True, overwrite=False, version='latest', filename=None, return_info=False):
	"""
	Downloads the given browser driver, and returns the path it was saved to.
	:param browser: The Driver to download. Pass as `pyderman.chrome/firefox`. Default Chrome.
	:param file_directory: The directory to save the driver.
	:param verbose: If printouts are okay during downloading.
	:param chmod: If True, attempt to make the downloaded driver executable.
	:param overwrite: If true, overwrite existing drivers of the same version.
	:param version: The version to download. Default 'latest'.
	:param filename: The filename to save the driver to. Defaults to driver-specific.
	:param return_info: If True, return an Object with more download information.
	:return: The absolute path of the downloaded driver, or None if something failed.
	"""

important point

Edge is experimental code, so it seems better to specify the version

Webdriver Manager for Python Scripts that make it easier to manage drivers for different browsers

Installation

pip install webdriver_manager

How to use

Until now, I downloaded the driver by hand every time there was an update, and in Chrome I set the path etc. like the following

So far


webdriver.Chrome('/home/user/drivers/chromedriver')
ChromeDriverManager(path=custom_path).install()

Instead

Chrome


from webdriver_manager.chrome import ChromeDriverManager

webdriver.Chrome(ChromeDriverManager().install())

It looks like this Firefox

Firefox


from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

IE

IE


from webdriver_manager.microsoft import IEDriverManager

driver = webdriver.Ie(IEDriverManager().install())

Opera

Opera


from webdriver_manager.opera import OperaDriverManager

driver = webdriver.Opera(executable_path=OperaDriverManager().install())

Webdriver Controller

CLI tool for managing web drivers?

Installation

pip install webdriver_controller

How to use

webdriver_controller [-h] {download,cleanup,list,start} ...
Webdriver controller
positional arguments:
  {download,cleanup,list,start}
download Download the Webdriver binary
Remove cleanup Webdriver binaries
list Display a list of downloaded Webdrivers
start Start Selenium

optional arguments:
  -h, --help This help message(Original)Show

webdriverdownloader

Installation

pip install webdriverdownloader

How to use

Firefox

Firedox


from webdriverdownloader import GeckoDriverDownloader
#Install the latest version
gdd = GeckoDriverDownloader()
# v0.20.Install version 0
gdd.download_and_install("v0.20.0")

Chrome

Chrome


from webdriverdownloader import  ChromeDriverDownloader
#Install the latest version
gdd =  ChromeDriverDownloader()
# v0.20.Install version 0
gdd.download_and_install("v0.20.0")

Opera (based on Chromium)

Opera(Chromium base)


from webdriverdownloader import  OperaChromiumDriverDownloader
#Install the latest version
gdd =  OperaChromiumDriverDownloader()
# v0.20.Install version 0
gdd.download_and_install("v0.20.0")

How to use as a CLI tool

webdriverdownloader browser:version 

When installing 2.38 of Chrome, the latest version of Firefox, v2.35 of opera

example


webdriverdownloader chrome:2.38 firefox opera:v.2.35

webdrivermanager

A script that automatically searches and downloads the latest version (or specific version) of the WebDriver binary and puts it in your path Same usage as webdriver downloader at present (2020/3/12)

Installation

pip install webdrivermanager

How to use

Firefox

Firedox


from webdriverdownloader import GeckoDriverDownloader
#Install the latest version
gdd = GeckoDriverDownloader()
# v0.20.Install version 0
gdd.download_and_install("v0.20.0")

Chrome

Chrome


from webdriverdownloader import  ChromeDriverDownloader
#Install the latest version
gdd =  ChromeDriverDownloader()
# v0.20.Install version 0
gdd.download_and_install("v0.20.0")

Opera (based on Chromium)

Opera(Chromium base)


from webdriverdownloader import  OperaChromiumDriverDownloader
#Install the latest version
gdd =  OperaChromiumDriverDownloader()
# v0.20.Install version 0
gdd.download_and_install("v0.20.0")

How to use as a CLI tool

webdriverdownloader browser:version 

If you have installed 2.38 of Chrome, the latest version of Firefox, v2.35 of opera

example


webdriverdownloader chrome:2.38 firefox opera:v.2.35

Recommended Posts

Module summary that automates and assists WebDriver installation with Python
Python installation and package management with pip
Installation of Python3 and Flask [Environment construction summary]
Drive WebDriver with python
[Python] Introduction to web scraping | Summary of methods that can be used with webdriver
Programming with Python and Tkinter
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
Python installation and basic grammar
Installation procedure for Python and Ansible with a specific version
Ruby, Python Module Installation Guide
Python debug and test module
python with pyenv and venv
Challenge Python3 and Selenium Webdriver
This and that for using Step Functions with CDK + Python
Python (Python 3.7.7) installation and basic grammar
Works with Python and R
The story of making a module that skips mail with python
Communicate with FX-5204PS with Python and PyUSB
Robot running with Arduino and python
Install Python 2.7.9 and Python 3.4.x with pip.
Neural network with OpenCV 3 and Python 3
AM modulation and demodulation with python
Installation of SciPy and matplotlib (Python)
[Python] font family and font with matplotlib
Scraping with Node, Ruby and Python
Scraping with Python, Selenium and Chromedriver
Cooperation between python module and API
[Code] Module and Python version output
JSON encoding and decoding with python
Hadoop introduction and MapReduce with Python
[GUI with Python] PyQt5-Drag and drop-
This and that of python properties
Reading and writing NetCDF with Python
Python3 socket module and socket communication flow
I played with PyQt5 and Python3
Easy modeling with Blender and Python
Summary of Python indexes and slices
Sugoroku game and addition game with python
FM modulation and demodulation with Python
E2E test to select select box with CasperJS, Nightmare and Python + WebDriver + PhantomJS
Solve with Python [100 past questions that beginners and intermediates should solve] (028 --033 breadth-first search)
Basic summary of scraping with Requests that beginners can absolutely understand [Python]
"Manim" that can draw animation of mathematical formulas and graphs with Python
I made a module PyNanaco that can charge nanaco credit with python
Installation of Visual studio code and installation of python
Data pipeline construction with Python and Luigi
Calculate and display standard weight with python
[Python] A program that creates stairs with #
FM modulation and demodulation with Python Part 3
Suddenly with Python PyInstaller No module named pyinstaller
[Automation] Manipulate mouse and keyboard with Python
Passwordless authentication with RDS and IAM (Python)
Implementation module "deque" in queue and Python
Using Python and MeCab with Azure Databricks
POST variously with Python and receive with Flask
Capturing images with Pupil, python and OpenCV
Fractal to make and play with Python
A memo with Python2.7 and Python3 on CentOS
CentOS 6.4 with Python 2.7.3 with Apache with mod_wsgi and Django
Dealing with "years and months" in Python