This code used to work perfectly. I formatted my PC yesterday and now it doesn’t work. I downloaded Python 3.12, installed selenium 4.16, downloaded chromedriver 120, did literally everything the same as before and now when I run the code it says
PS C:\Users\Thierry> & C:/Users/Thierry/AppData/Local/Programs/Python/Python312/python.exe c:/Users/Thierry/Desktop/tinder.py
Traceback (most recent call last):
File “c:\Users\Thierry\Desktop\tinder.py”, line 15, in
driver = webdriver.Chrome(service=service, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Thierry\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chrome\webdriver.py”, line 45, in init
super().init(
File “C:\Users\Thierry\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chromium\webdriver.py”, line 49, in init
self.service.path = DriverFinder.get_path(self.service, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Thierry\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\driver_finder.py”, line 44, in get_path
raise NoSuchDriverException(f"Unable to locate or obtain driver for {options.capabilities[‘browserName’]}")
selenium.common.exceptions.NoSuchDriverException: Message: Unable to locate or obtain driver for chrome; For documentation on this error, please visit: Unable to Locate Driver Error | Selenium
The code is a tinder bot. What I would always do was open Command Prompt and run “C:/Program Files/Google/Chrome/Application/chrome” --remote-debugging-port=9222 --user-data-dir=“C:/Users/Me/Desktop/Tutorial”, then open Visual Studio Code and run the code below. It always worked until I formatted.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time
opening_line = ""
number_of_swipes = 10000
path = "C:/Users/Me/Desktop/chromedriver"
service = Service(executable_path=path)
web = 'https://tinder.com/'
options = Options()
options.add_experimental_option("debuggerAddress", "localhost:9222")
driver = webdriver.Chrome(service=service, options=options)
driver.get(web)
time.sleep(3)
for i in range(number_of_swipes):
try:
like_button = driver.find_element(by='xpath', value='//button//span[text()="Like"]')
driver.execute_script("arguments[0].click();", like_button)
time.sleep(0.1)
its_match_window = driver.find_element(by='xpath', value='//textarea[@placeholder="Say something nice!"]')
its_match_window.send_keys(opening_line)
time.sleep(1)
send_message_button = driver.find_element(by='xpath', value='//button/span[text()="Send"]')
send_message_button.click()
time.sleep(1)
close_its_match_window = driver.find_element(by='xpath', value='//button[@title="Back to Tinder"]')
close_its_match_window.click()
except:
try:
box = driver.find_element(by='xpath', value='//button/span[text()="Maybe later"] | //button/span[text()="Not interested"] | //button/span[text()="No Thanks"]')
box.click()
except:
pass
What can I do? I don’t know anything about Python, all I did was watch this Youtube video and do as he says. Like I said, it was working good until I formatted my PC yesterday. Thanks!