-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbumbleMethods.py
31 lines (25 loc) · 1020 Bytes
/
bumbleMethods.py
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
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import uuid
import os
import urllib.request
# this downloads all pictures into a folder labelled by the profiles name age and a uuid
def find_download_all_pictures(driver, data_folder):
# first make the folder name
idnum = str(uuid.uuid4())
string = idnum
# make the directory
savePath = os.path.join(data_folder, string)
os.mkdir(savePath)
pictures = driver.find_elements(By.CLASS_NAME, "media-box__picture-image")
for i in range(len(pictures)):
pic = pictures[i]
src = pic.get_attribute("src")
urllib.request.urlretrieve(src, os.path.join(savePath, f"image_{i}.png"))
return string
# like this profile that we are working on
def like_profile(driver):
driver.find_element(By.CSS_SELECTOR, "body").send_keys(Keys.RIGHT)
# dislike the profile we are workig on
def dislike_profile(driver):
driver.find_element(By.CSS_SELECTOR, "body").send_keys(Keys.LEFT)