forked from oalsing/Automagic_Tinder_Fire_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbumble.py
More file actions
192 lines (155 loc) · 5.57 KB
/
bumble.py
File metadata and controls
192 lines (155 loc) · 5.57 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#! /usr/bin/python3
import datetime
import re
import logging
from io import BytesIO
from PIL import Image
import numpy as np
from io_helpers import save_image
from main import extract_faces, SVR_CLASSIFIER, convert_face_features
import requests
from selenium import webdriver
from selenium.common.exceptions import *
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import argparse
from time import sleep
logging.basicConfig(level=logging.INFO)
def log_in_with_facebook(driver, email, password):
while True:
try:
button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[contains(@class, 'color-provider-facebook')]")))
button.click()
break
except NoSuchElementException:
pass
# switch to facebook window
driver.switch_to.window(driver.window_handles[1])
# try to enter email until it loads
while True:
try:
driver.find_element_by_xpath("//input[@id='email']").send_keys(email)
break
except NoSuchElementException as e:
pass
# enter password and click submit
driver.find_element_by_xpath("//input[@id='pass']").send_keys(password)
driver.find_element_by_xpath("//input[@id='u_0_0']").click()
try:
# try to click continue until it loads
while True:
try:
driver.find_element_by_xpath("//button[contains(text(), 'Continue as')]").click()
break
except NoSuchElementException:
pass
except:
pass
# back to main window
driver.switch_to.window(driver.window_handles[0])
def dismiss_match(driver):
try:
driver.find_element_by_xpath("//*[contains(@class, 'button--transparent')]").click()
return True
except NoSuchElementException:
return False
def all_done(driver):
# check to see if we are all caught up
try:
driver.find_element_by_xpath("//*[contains(text(), 'all caught up')]")
return True
except NoSuchElementException:
pass
try:
driver.find_element_by_xpath("//*[contains(text(), 'bees in your area')]")
return True
except NoSuchElementException:
pass
return False
def size(url):
try:
url_size = re.findall('wm_offs=(\d+)x(\d+)', url)
return max(map(int, url_size[0]))
except:
return 0
def analyze_images(images):
runtime = datetime.datetime.now().isoformat()
urls = [url for url in images if size(url) > 72]
likes = []
images = []
for photo in urls:
try:
response = requests.get(photo)
image = Image.open(BytesIO(response.content)).convert('RGB')
faces = extract_faces(image)
for face in faces:
likes.append(SVR_CLASSIFIER.predict(np.asarray(convert_face_features(face))))
images.append(face)
except Exception as e:
logging.error(e)
if likes:
logging.info('All ratings {}'.format(likes))
max_like = max(likes)
formatted_max_like = "{0:.2f}".format(float(max_like))
if max_like > 3.5:
logging.info(f'Like, rating {formatted_max_like}')
save_image(images[likes.index(max_like)], '{}_{}.jpg'.format(formatted_max_like, runtime), 'autolike')
return True
else:
logging.info(f'Dislike, rating {max_like}')
save_image(images[likes.index(max_like)], '{}_{}.jpg'.format(formatted_max_like, runtime), 'autodislike')
return False
else:
logging.info('Dislike - No faces')
return False
def like(driver):
try:
images = driver.find_elements_by_tag_name('img')
urls = [image.get_attribute('src') for image in images]
return analyze_images(urls)
except StaleElementReferenceException as e:
logging.error(e)
return False
def swipe_left(driver):
try:
# dismiss_match(driver)
driver.find_element_by_xpath("//div[contains(@class, 'encounters-action--dislike')]").click()
return True
except Exception as e:
logging.error(e)
return not all_done(driver)
def swipe_right(driver):
try:
# dismiss_match(driver)
driver.find_element_by_xpath("//div[contains(@class, 'encounters-action--like')]").click()
return True
except Exception as e:
logging.error(e)
return not all_done(driver)
if __name__ == "__main__":
# parse arguments
parser = argparse.ArgumentParser(description="Auto swiper for bumble. Pass your Facebook email and password.")
parser.add_argument('email', metavar='email', type=str, nargs=1,
help='Your Facebook email')
parser.add_argument('password', metavar='password', type=str, nargs=1,
help='Your Facebook password')
args = parser.parse_args()
email = args.email
password = args.password
# open driver
driver = webdriver.Firefox()
driver.get("https://bumble.com/login")
log_in_with_facebook(driver, email, password)
# keep swiping right until we're caught up
while True:
# refresh page until we get new matches
if like(driver):
result = swipe_right(driver)
else:
result = swipe_left(driver)
if not result:
print("All caught up... Refreshing until matches available... Ctrl-C to quit.")
driver.execute_script("location.reload(true);")
sleep(5)
driver.close()