4 min read

Automate Your Swipes on Tinder or Bumble using Python

This project is kind of cringe 😅 but I guess it's a fun way to work on some bot making skills. It seemed to be all the rage during the thick of the pandemic.
Automate Your Swipes on Tinder or Bumble using Python
GitHub - ethanolivertroy/dating-app-automation
Contribute to ethanolivertroy/dating-app-automation development by creating an account on GitHub.

Objective: Automate Swiping on Dating Apps Using Python because Online Dating Sucks

Let's face it...dating in 2020 in 2023 sucks.

So to remedy this let's whip up something in python to deal with the new face of dating which is unfortunately online dating apps.

At the same time we get to practice the skill of creating a python bot that could be used to automate other things as well.

Building a Bot: Selecting and Interacting

Building this sort of bot is simply a series of selecting objects within the web app and interacting with that object via entering inputs and clicks

It's about translating the needed actions into code steps...

Get Stuff We Will Need to Build

Chrome Driver

  1. Download the most recent Chrome Driver https://chromedriver.chromium.org/downloads
  2. Move the chrome driver file into your bin
mv ~/Downloads/chromedriver /usr/local/bin

Create a File and Virtual Environment

  1. Brew install virtualenv (using https://brew.sh/)
    https://virtualenv.pypa.io/en/latest/
  2. Create a file for the bot
mkdir tinder_bot
touch tinder_bot.py
  1. Create a Virtual Environment and Activate It
virtualenv venv
source venv/bin/activate

Selenium

  1. Install Selenium
pip install selenium

Create a secrets file

  1. Secrets will be a .py file that we will create with the username and password for the facebook login
# name this secrets.py
username = 'usernameXX'
password = 'passwordXX'

What do we need the bot to do in order to login?

  1. Click on the "Login with Facebook" button
  2. Enter our e-mail address
  3. Enter our password
  4. Click Login

Import All Needed Libraries in tinder_bot.py

from selenium import webdriver

from selenium.webdriver.common.by import By

from time import sleep

from secrets import username, password

Now we start working on the actual tinder_bot.py file.

We create a new class for the bot and within that class we will start webdriver.Chrome

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

Add a login function to open the website

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

I selected the buttons by finding the element by XPath. There are other ways to do this such as by ID which I'll use later.

Add Sleeps

        sleep(2)

        first_click = self.driver.find_element(By.XPATH, '//*[@id="t-2073920312"]/div/div[1]/div/main/div[1]/div/div/div/div/header/div/div[2]/div[2]/a/span')
        first_click.click()

        sleep (1)

        fb_btn = self.driver.find_element(By.XPATH, '//*[@id="t492665908"]/div/div/div[1]/div/div[3]/span/div[2]/button')
        fb_btn.click()

The sleeps are added to give the bot pause. The ☝🏾 above allows us to get in with the facebook login information held in secrets.py

Multiple Windows

Unfortunately, we have to manage several windows

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

Pass the secrets into the facebook login

        email_in = self.driver.find_element(By.XPATH, '//*[@id="email"]')
        email_in.send_keys(username)

        pw_in = self.driver.find_element(By.XPATH, '//*[@id="pass"]')
        pw_in.send_keys(password)

Click the login button

        login_btn = self.driver.find_element(By.ID, 'loginbutton')
        login_btn.click()

        self.driver.switch_to.window(base_window)

Get Rid of Pop-ups

        popup_1 = self.driver.find_element(By.XPATH, '//*[@id="t492665908"]/div/div/div/div/div[3]/button[1]')
        popup_1.click()

        popup_2 = self.driver.find_element(By.XPATH, '//*[@id="t492665908"]/div/div/div/div/div[3]/button[1]')
        popup_2.click()

Define some functions for liking, disliking, and autoswipe

# like
    def like(self):
        like_btn = self.driver.find_element(By.CSS_SELECTOR, '[data-testid="gamepadLike"]')
        like_btn.click()
# dislike
    def dislike(self):
        dislike_btn = self.driver.find_element(By.CSS_SELECTOR, '[data-testid="gamepadDislike"]')
        dislike_btn.click()
# autoswipes
def auto_swipe(self):
        while True:
            sleep(0.5)
            try:
                self.like()
            except Exception:
                try:
                    self.close_popup()
                except Exception:
                    self.close_match()

Close some windows and finish off the code

    def close_popup(self):
        popup_3 = self.driver.find_element(By.CSS_SELECTOR, '[data-testid="cancel"]')
        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()

    def close_slikepop(self):
        slikepop = self.driver.find_element (By.XPATH, '//*[@id="q1954245907"]/div/div/button[2]')
        slikepop.click()

bot = Tinderbot()
bot.login()
Tinder Automation according to Midjourney Version 4

Bumble and Hinge

This whole process works pretty much the same with any dating app that has a web app. You just have to make a few adjustments.

If one selecting method doesn't work I just rotate to another.

  • XPATH
  • ID
  • CSS_SELECTOR
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from secrets import username, password

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

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

        sleep(2)

        first_click = self.driver.find_element(By.XPATH, '')
        first_click.click()

        sleep (1)

        fb_btn = self.driver.find_element(By.XPATH, '')
        fb_btn.click()

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

        email_in = self.driver.find_element(By.XPATH, '')
        email_in.send_keys(username)

        pw_in = self.driver.find_element(By.XPATH, '')
        pw_in.send_keys(password)

        login_btn = self.driver.find_element(By.ID, 'loginbutton')
        login_btn.click()

        self.driver.switch_to.window(base_window)


        popup_1 = self.driver.find_element(By.XPATH, '')
        popup_1.click()

        popup_2 = self.driver.find_element(By.XPATH, '')
        popup_2.click()

    def like(self):
        like_btn = self.driver.find_element(By.CSS_SELECTOR, '[data-qa-icon-name="floating-action-yes"]')
        like_btn.click()

    def dislike(self):
        dislike_btn = self.driver.find_element(By.CSS_SELECTOR, '[data-testid="gamepadDislike"]')
        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, '')
        popup_3.click()

    def close_match(self):
        match_popup = self.driver.find_element(By.XPATH, '')
        match_popup.click()

bot = Bumblebot()
bot.login()