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)