0

I made a web-scraping script using Selenium, Pandas, bf4 and GeckoDriver

import requests
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from webdriver_manager.firefox import GeckoDriverManager

url = "https://example/url/target"
    
option = Option()
option.headlers = True
driver = webdriver.Firefox(executable_path=r'C:\Users\Public\geckodriver.exe')
driver.get(url)

With this code the script works 100% but as I need it to be a portable application (transfer to other computers) I don't want the user to have to manually specify the Geckodriver path, let alone have to download it.


Geckodriver has an auto-installer but in all the ways that I try to make i get an error, searching here in the forum I found this alternative (and the error)

url = "https://example/url/target"

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

driver.get("https:www.python.org")
driver.get(url)

Result:

ConnectionError: HTTPSConnectionPool(host = 'api.github.com', port=443): Max retries exceeded with url: /repos/mozilla/geckodriver/releases/latest (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000025186487F98>: Failed to stabilize a new connection: [Errno 11001 getaddriinfo failed',))

I also tried following the: https://pypi.org/project/geckodriver-autoinstaller/#description :

import geckodriver_autoinstaller
geckodriver_autoinstaller.install()

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

Result:

<urlopen error [Errno 11001] getaddrinfo failed>

All these options I tested also with socket.getddrinfo('localhost', 8080) and also using Git hub personal Token in os.environ['GH_TOKEN'] = 'exampletoken'

Does anyone know why I'm not able to automate the driver installation?


W10 64 bit, Firefox Latest Version, Libs and anaconda latest version, Python = 3.6, Internet with VPN (from work)

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
MatheusHRV
  • 1
  • 1
  • 1

1 Answers1

0

Possibly a typo, however instead of rGeckoDriverManager() you should have used GeckoDriverManager() within the line:

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

Effectively your code block will be:

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
driver.get("https://www.google.com")

Console Output:

====== WebDriver manager ======
Current firefox version is 97.0
Get LATEST geckodriver version for 97.0 firefox
Driver [C:\Users\debanjan.bhattacharj\.wdm\drivers\geckodriver\win64\v0.30.0\geckodriver.exe] found in cache
C:\Users\debanjan.bhattacharj\Desktop\Python Programs\Selenium3-GeckoDriverManager.py:8: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
  

PS: Using executable_path has been deprecated and you have pass in a Service object.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352