I was trying webscraping using selenium. I ran this code:
from selenium import webdriver
PATH = "C:\\Users\\winwin\\Documents\\Visual Studio\\chromedriver.exe"
URL = "https://scratch.mit.edu/projects/994662672/"
driver = webdriver.Chrome(PATH)
driver.get(URL)
But it showed an error:
Exception has occurred: AttributeError
'str' object has no attribute 'capabilities'
AttributeError: 'str' object has no attribute 'capabilities'
During handling of the above exception, another exception occurred:
File "C:\Users\winwin\Documents\Visual Studio\Python\ScratchScraping\main.py", line 6, in <module>
driver = webdriver.Chrome(PATH)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'
What do I do?
I know that I setted up selenium and the webdriver correctly.
As long as you are using Selenium 4.6+, there is no need to manage your own chromedriver any more because they added Selenium Manager. Your code can now be simplified to
from selenium import webdriver
URL = "https://scratch.mit.edu/projects/994662672/"
driver = webdriver.Chrome()
driver.get(URL)