|
| 1 | +from selenium import webdriver |
| 2 | +from selenium.webdriver.common.keys import Keys |
| 3 | +from selenium.webdriver.common.by import By |
| 4 | +from selenium.common.exceptions import NoSuchElementException, ElementClickInterceptedException |
| 5 | +import os |
| 6 | +from time import sleep |
| 7 | +from dotenv import load_dotenv |
| 8 | + |
| 9 | +load_dotenv(".env") |
| 10 | +MY_EMAIL = os.getenv("MY_EMAIL") |
| 11 | +MY_PASSWORD = os.getenv("MY_PASSWORD") |
| 12 | + |
| 13 | +chrome_driver_path = ("C:\Development\chromedriver.exe") |
| 14 | +driver = webdriver.Chrome(executable_path=chrome_driver_path) |
| 15 | + |
| 16 | +driver.get("http://www.tinder.com") |
| 17 | + |
| 18 | +sleep(2) |
| 19 | +login_button = driver.find_element(By.XPATH, value= '//*[@id="t-2073920312"]/div/div[1]/div/main/div[1]/div/div/div/div/header/div/div[2]/div[2]/a') |
| 20 | +login_button.click() |
| 21 | + |
| 22 | +sleep(2) |
| 23 | +fb_login = driver.find_element(By.XPATH, value='//*[@id="t492665908"]/div/div/div[1]/div/div[3]/span/div[2]/button/span[2]') |
| 24 | +fb_login.click() |
| 25 | + |
| 26 | +sleep(2) |
| 27 | +base_window = driver.window_handles[0] |
| 28 | +fb_login_window = driver.window_handles[1] |
| 29 | +driver.switch_to.window(fb_login_window) |
| 30 | + |
| 31 | +email = driver.find_element(By.XPATH, value='//*[@id="email"]') |
| 32 | +password = driver.find_element(By.XPATH, value='//*[@id="pass"]') |
| 33 | + |
| 34 | +email.send_keys(MY_EMAIL) |
| 35 | +password.send_keys(MY_PASSWORD) |
| 36 | +password.send_keys(Keys.ENTER) |
| 37 | + |
| 38 | +driver.switch_to.window(base_window) |
| 39 | + |
| 40 | +sleep(5) |
| 41 | +allow_location_button = driver.find_element(By.XPATH, value='//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]') |
| 42 | +allow_location_button.click() |
| 43 | +notifications_button = driver.find_element(By.XPATH, value='//*[@id="modal-manager"]/div/div/div/div/div[3]/button[2]') |
| 44 | +notifications_button.click() |
| 45 | +cookies = driver.find_element(By.XPATH, value='//*[@id="content"]/div/div[2]/div/div/div[1]/button') |
| 46 | +cookies.click() |
| 47 | + |
| 48 | +for n in range(100): |
| 49 | + sleep(1) |
| 50 | + try: |
| 51 | + print("called") |
| 52 | + like_button = driver.find_element(By.XPATH, value='//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div[1]/div/div[2]/div[4]/button') |
| 53 | + like_button.click() |
| 54 | + except ElementClickInterceptedException: |
| 55 | + try: |
| 56 | + match_popup = driver.find_element(By.CSS_SELECTOR, value=".itsAMatch a") |
| 57 | + match_popup.click() |
| 58 | + except NoSuchElementException: |
| 59 | + sleep(2) |
| 60 | + |
| 61 | +driver.quit() |
0 commit comments