Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added added updates for tinder bot and started okcupid bot #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
to run:
- download chromedriver, unzip, move to `/usr/local/bin` (mac os / linux)
- `pip install selenium`

create a secrets.py file with variables:
```
username = 'your_username'
password = 'your_password'
## Install
### Fedora:
```
sudo dnf -y install chromedriver
```
### Mac os / other linuxes linux

- download chromedriver, unzip, move to `/usr/local/bin` ()

## Install selenium with pip
```
pip install selenium
```

## create a secrets.py file with variables:
```
cat << EOF > secrets.py \
tinder_username = ''
tinder_password = ''
okcupid_username = ''
okcupid_password = ''
EOF
```

```
python -i tinder_bot.py

python -i okcupid_bot.py

```

please add more features to this, would be awesome to see what you can come up w
Expand Down
84 changes: 84 additions & 0 deletions okcupid_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from selenium import webdriver
from time import sleep

from secrets import okcupid_username, okcupid_password

class TinderBot():
def __init__(self):
self.driver = webdriver.Chrome()

def login(self):
self.driver.get('https://www.okcupid.com/login')

cookie_btn = self.driver.find_element_by_xpath('//*[@class="optanon-allow-all accept-cookies-button"]')
cookie_btn.click()
sleep(0.5)

email_in = self.driver.find_element_by_xpath('//*[@id="username"]')
email_in.send_keys(okcupid_username)

pw_in = self.driver.find_element_by_xpath('//*[@id="password"]')
pw_in.send_keys(okcupid_password)
sleep(0.5)
try:
recaptcha_btn = self.driver.find_element_by_xpath('//*[@id="recaptcha-anchor"]/div[1]')
recaptcha_btn.click()
except Exception:
sleep(0.5)

next_btn = self.driver.find_element_by_xpath('//*[@id="OkModal"]/span/div/div[1]/div/div/div/div[2]/div/div/div[2]/div/form/div[2]/input')
next_btn.click()

sleep(1)

try:
fb_btn = self.driver.find_element_by_xpath('//*[@id="modal-manager"]/div/div/div/div/div[3]/div[2]/button')
fb_btn.click()

# switch to login popup
base_window = self.driver.window_handles[0]
self.driver.switch_to.window(self.driver.window_handles[1])
sleep(2)


self.driver.switch_to.window(base_window)

popup_1 = self.driver.find_element_by_xpath('//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]')
popup_1.click()

sleep(2)
popup_2 = self.driver.find_element_by_xpath('//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]')
popup_2.click()

except Exception:
sleep(0.5)

def like(self):
like_btn = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div[1]/div/div[2]/button[3]')
like_btn.click()

def dislike(self):
dislike_btn = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/main/div[1]/div/div/div[1]/div/div[2]/button[1]')
dislike_btn.click()

def auto_swipe(self):
while True:
sleep(0.5)
try:
self.like()
except Exception:
try:
self.close_popup()
except Exception:
self.close_match()

def close_popup(self):
popup_3 = self.driver.find_element_by_xpath('//*[@id="modal-manager"]/div/div/div[2]/button[2]')
popup_3.click()

def close_match(self):
match_popup = self.driver.find_element_by_xpath('//*[@id="modal-manager-canvas"]/div/div/div[1]/div/div[3]/a')
match_popup.click()

bot = TinderBot()
bot.login()
13 changes: 8 additions & 5 deletions tinder_bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from selenium import webdriver
from time import sleep

from secrets import username, password
from secrets import tinder_username, tinder_password

class TinderBot():
def __init__(self):
Expand All @@ -17,22 +17,25 @@ def login(self):

# switch to login popup
base_window = self.driver.window_handles[0]
self.driver.switch_to_window(self.driver.window_handles[1])
self.driver.switch_to.window(self.driver.window_handles[1])

email_in = self.driver.find_element_by_xpath('//*[@id="email"]')
email_in.send_keys(username)
email_in.send_keys(tinder_username)

pw_in = self.driver.find_element_by_xpath('//*[@id="pass"]')
pw_in.send_keys(password)
pw_in.send_keys(tinder_password)

login_btn = self.driver.find_element_by_xpath('//*[@id="u_0_0"]')
login_btn.click()

self.driver.switch_to_window(base_window)
sleep(2)
self.driver.switch_to.window(base_window)
sleep(2)

popup_1 = self.driver.find_element_by_xpath('//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]')
popup_1.click()

sleep(2)
popup_2 = self.driver.find_element_by_xpath('//*[@id="modal-manager"]/div/div/div/div/div[3]/button[1]')
popup_2.click()

Expand Down