Repository navigation
Expand file tree
/
Copy pathDay50.py
More file actions
79 lines (58 loc) · 2.56 KB
/
Copy pathDay50.py
File metadata and controls
79 lines (58 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
from time import sleep
from dotenv import load_dotenv
from selenium import webdriver
from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
load_dotenv()
FB_EMAIL = os.getenv('FB_EMAIL')
FB_PASSWORD = os.getenv("FB_PASSWORD")
wait_time = 2
print("Day 50 - 100 Days of Code.")
print("Welcome to Tinder Auto Swiping Bot.")
driver = webdriver.Chrome()
driver.get("http://www.tinder.com")
sleep(wait_time)
login_button = driver.find_element(By.XPATH, value='//*[text()="Log in"]')
login_button.click()
sleep(wait_time)
fb_login = driver.find_element(By.XPATH, value='//*[@id="modal-manager"]/div/div/div[1]/div/div[3]/span/div[2]/button')
fb_login.click()
sleep(wait_time)
base_window = driver.window_handles[0]
fb_login_window = driver.window_handles[1]
driver.switch_to.window(fb_login_window)
print(driver.title)
email = driver.find_element(By.XPATH, value='//*[@id="email"]')
password = driver.find_element(By.XPATH, value='//*[@id="pass"]')
email.send_keys(FB_EMAIL)
password.send_keys(FB_PASSWORD)
password.send_keys(Keys.ENTER)
driver.switch_to.window(base_window)
print(driver.title)
sleep(wait_time)
allow_location_button = driver.find_element(By.XPATH, value='//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]')
allow_location_button.click()
notifications_button = driver.find_element(By.XPATH, value='//*[@id="modal-manager"]/div/div/div/div/div[3]/button[2]')
notifications_button.click()
cookies = driver.find_element(By.XPATH, value='//*[@id="content"]/div/div[2]/div/div/div[1]/button')
cookies.click()
# Tinder free tier only allows 100 "Likes" per day. If you have a premium account, feel free to change to a while loop.
for n in range(100):
# Add a 2-second delay between likes.
sleep(wait_time)
try:
like_button = driver.find_element(by=By.XPATH,
value='//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div['
'1]/div/div[2]/div[4]/button')
like_button.click()
# Catches the cases where there is a "Matched" pop-up in front of the "Like" button:
except ElementClickInterceptedException:
try:
match_popup = driver.find_element(By.CSS_SELECTOR, value=".itsAMatch a")
match_popup.click()
# Catches the cases where the "Like" button has not yet loaded, so wait 2 seconds before retrying.
except NoSuchElementException:
sleep(wait_time)
driver.quit()