I am trying to do a selenium program where I am trying to do a basic web scrape where I am able to get the title of the website. Yet, whenever I try to do the most basic web scrape using selenium with all the web drivers already installed I get a bunch of errors which I can’t interpret and I still can’t find the solution to my problems anywhere online.
This is the code I typed into vs code:
from selenium import webdriver
PATH = "C:Program Files (x86)geckodriver.exe"
driver = webdriver.Firefox(PATH)
driver.get("https://www.bestbuy.com")
print(driver.title)
driver.quit()
This is the error response I received:
c:Program Files (x86)VS CodeProduct Scalper.py:3: SyntaxWarning: invalid escape sequence 'P'
PATH = "C:Program Files (x86)geckodriver.exe"
Traceback (most recent call last):
File "c:Program Files (x86)VS CodeProduct Scalper.py", line 4, in <module>
driver = webdriver.Firefox(PATH)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersvictoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesseleniumwebdriverfirefoxwebdriver.py", line 57, in __init__
if finder.get_browser_path():
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersvictoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesseleniumwebdrivercommondriver_finder.py", line 47, in get_browser_path
return self._binary_paths()["browser_path"]
^^^^^^^^^^^^^^^^^^^^
File "C:UsersvictoAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesseleniumwebdrivercommondriver_finder.py", line 56, in _binary_paths
browser = self._options.capabilities["browserName"]
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'
FlankMan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.