1
+ from selenium import webdriver
2
+ import os
3
+ from selenium .webdriver .common .keys import Keys
4
+ from selenium .common .exceptions import ElementClickInterceptedException , NoSuchElementException
5
+ from time import sleep
6
+
7
+ FB_EMAIL = os .environ .get ("fbemail" )
8
+ FB_PASSWORD = os .environ .get ("fbpass" )
9
+
10
+ chrome_driver_path = os .environ .get ("driver_path" )
11
+ driver = webdriver .Chrome (executable_path = chrome_driver_path )
12
+
13
+ driver .get ("http://www.tinder.com" )
14
+
15
+ sleep (2 )
16
+ login_button = driver .find_element_by_xpath ('//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/header/div[1]/div[2]/div/button' )
17
+ login_button .click ()
18
+
19
+ sleep (2 )
20
+ fb_login = driver .find_element_by_xpath ('//*[@id="modal-manager"]/div/div/div[1]/div/div[3]/span/div[2]/button' )
21
+ fb_login .click ()
22
+
23
+ sleep (2 )
24
+ base_window = driver .window_handles [0 ]
25
+ fb_login_window = driver .window_handles [1 ]
26
+ driver .switch_to .window (fb_login_window )
27
+ print (driver .title )
28
+
29
+ email = driver .find_element_by_xpath ('//*[@id="email"]' )
30
+ password = driver .find_element_by_xpath ('//*[@id="pass"]' )
31
+
32
+ email .send_keys (FB_EMAIL )
33
+ password .send_keys (FB_PASSWORD )
34
+ password .send_keys (Keys .ENTER )
35
+
36
+ driver .switch_to .window (base_window )
37
+ print (driver .title )
38
+
39
+ sleep (5 )
40
+ allow_location_button = driver .find_element_by_xpath ('//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]' )
41
+ allow_location_button .click ()
42
+ notifications_button = driver .find_element_by_xpath ('//*[@id="modal-manager"]/div/div/div/div/div[3]/button[2]' )
43
+ notifications_button .click ()
44
+ cookies = driver .find_element_by_xpath ('//*[@id="content"]/div/div[2]/div/div/div[1]/button' )
45
+ cookies .click ()
46
+
47
+ for n in range (100 ):
48
+ sleep (1 )
49
+ try :
50
+ print ("called" )
51
+ like_button = driver .find_element_by_xpath (
52
+ '//*[@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 (".itsAMatch a" )
57
+ match_popup .click ()
58
+ except NoSuchElementException :
59
+ sleep (2 )
60
+
61
+ driver .quit ()
0 commit comments