Skip to content

Instantly share code, notes, and snippets.

@kotakagi0914
Created October 13, 2022 09:47
Show Gist options
  • Save kotakagi0914/902bd38e7303592b6a8df9a3cc20f8d0 to your computer and use it in GitHub Desktop.
Save kotakagi0914/902bd38e7303592b6a8df9a3cc20f8d0 to your computer and use it in GitHub Desktop.
import csv, random, time
from inspect import getmodule
from tinderbotz.session import Session
from tinderbotz.helpers.constants_helper import *
# CITY_INFO = ("New York", 40.76187, -73.98576)
# CITY_INFO = ("Seoul", 37.5665, 126.9780)
CITY_INFO = ("Tokyo", 35.69126, 139.70103)
MAX_COUNT = 2000
if __name__ == "__main__":
# creates instance of session
session = Session()
# session = Session(headless=True)
# set a custom location
session.set_custom_location(latitude=CITY_INFO[1], longitude=CITY_INFO[2])
# replace this with your own email and password!
email = "<email address>"
password = "<password>"
# login using your google account with a verified email! Alternatively, you can use Facebook login
session.login_using_facebook(email, password)
# adjust allowed distance for geomatches
# Note: PARAMETER IS IN KILOMETERS!
session.set_distance_range(km=15)
# set range of prefered age
session.set_age_range(18, 28)
# set interested in gender(s) -> options are: WOMEN, MEN, EVERYONE
session.set_sexuality(Sexuality.WOMEN)
# Create a csv file
file_name = "/tmp/{city}_{count}.csv"
f = open(file_name.format(city = CITY_INFO[0], count = MAX_COUNT), 'w')
writer = csv.writer(f)
# Add header
writer.writerow(['age', 'bio'])
# start scraping as much geomatches as possible
count = 0
refresh_count = 0
while count < MAX_COUNT:
geomatch = session.get_geomatch()
# check if crucial data is not empty (This will rarely be the case tho, but we want a 'clean' dataset
if geomatch.get_age() is not None \
and geomatch.get_bio() is not None:
count += 1
print(str(count) + ": " + str(geomatch.get_age()) + ", " + geomatch.get_bio())
# Add line to the csv file.
writer.writerow([geomatch.get_age(), geomatch.get_bio()])
# account is scraped, now dislike and go next (since dislikes are infinite)
# NOTE: if no amount is passed, it will dislike once -> same as => dislike(amount=1)
# NOTE: if you have TinderPlus, -Gold or -Platinum you could also use session.like()
session.dislike()
else:
# refresh webpage once in five times and go for another geomatch
refresh_count += 1
session.dislike()
if refresh_count > 5:
refresh_count = 0
session.browser.refresh()
# make a random sleep between dislikes between 0 and 3 seconds to mimic looks human-like, not spammy behaviour
sleepy_time = random.random() * 3
time.sleep(sleepy_time)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment