For those who want her but don't have the time, I would like to automate + alpha the free and easy-to-use matching app tinder.
・ Facebook account ・ Tinder account Please use facebook for automation of tinder registration. If you have any problems, we recommend that you create a new account to prevent your body from getting caught (laughs).
You must get an access token to log in to tinder using the api. Please note that the method of obtaining an access token will change immediately due to changes in the specifications of the site, so there is a possibility that the method you can do now will not be possible. I'm pretty stuck here. First, put in the library to get the tinder-token. (Reference: https://pypi.org/project/tinder-token/)
pip install tinder-token
Once in, try creating and running the following program. If you don't have the required library, please add it as appropriate.
get_token.py
from tinder_token.facebook import TinderTokenFacebookV2
mail = "Email address for facebook login"
password = "facebook password"
facebook = TinderTokenFacebookV2()
def sample_email_password(email: str, password: str) -> (str, str):
return facebook.get_tinder_token(fb_email=email, fb_password=password)
api_token = sample_email_password(mail,password)[0]
print(api_token)
If you execute this and a long character string is displayed, the acquisition is successful.
Now that you have the api code with the code above, you can finally log in.
import requests
s = requests.Session()
#Log in to Tinder
headers = {"X-Auth-Token": api_token, "Content-type": "application/json",
"User-agent": "Tinder/10.1.0 (iPhone; iOS 12.1; Scale/2.00)"}
s.headers.update(headers)
meta = s.get("https://api.gotinder.com/meta")
print(meta.text)
Put the api token you got earlier in the variable api_token. It is easier to connect the cords, so we recommend connecting them. It's okay if your information comes out in a row.
You can collect user information near your favorite points by passing latitude / longitude information in post. Various information such as the user's name and ID photo are stored in the user variable. Since this program gets the name, the name should be output in a smooth manner.
url = "https://api.gotinder.com/" + endpoint
latitude = "latitude"
longitude = "longitude"
params = {"lat": latitude, "lon": longitude}
response = s.post(url, data=json.dumps(params))
limit = 10
params = {"limit": limit}
for i in range(3):
users = s.post("https://api.gotinder.com/user/recs", data=json.dumps(params))
content = users.content
if len(content) > 0:
content = content.decode("utf-8")
content = json.loads(content)
else:
break
#print(content)
for user in content["results"]:
#print(user)
print(user["name"])
It is possible to like any id by hitting / like / {id} with get.
url = "https://api.gotinder.com/" + endpoint
latitude = "latitude"
longitude = "longitude"
params = {"lat": latitude, "lon": longitude}
response = s.post(url, data=json.dumps(params))
limit = 10
params = {"limit": limit}
for i in range(3):
users = s.post("https://api.gotinder.com/user/recs", data=json.dumps(params))
content = users.content
if len(content) > 0:
content = content.decode("utf-8")
content = json.loads(content)
else:
break
#print(content)
for user in content["results"]:
#print(user)
print(user["name"])
id = user["_id"]
#Swipe right
s.get("https://api.gotinder.com/like/{}".format(id))
It's true that the number of encounters is important, but I thought of an option for those who still want quality. Do you know the Face ++ API? FaceAPI was developed by a Chinese company and is a terrifying API that scores the beauty of the face, the so-called facial deviation value. The great thing about this API is that it can be used for free.
Register from the following URL. https://console.faceplusplus.com/register After logging in, look at the API Key page and make a note of the API Key and API secret.
It is made into a class considering cooperation with tinder. Place the photo you want to judge in the same directory as the program, and set test.jpeg to the file name of the image you want to judge, and the score will be output. By the way, Mr. Shin 〇〇 was 88.74 points. It's a really high score. I think it's a good idea to try some of them yourself and see the market view.
faceplus
import requests
import base64
class FacePlus:
def __init__(self,key,secret):
self.key = key
self.secret = secret
self.endpoint = 'https://api-us.faceplusplus.com'
def judge_face(self,path):
img_file = base64.encodestring(open(path, 'rb').read())
response = requests.post(
self.endpoint + '/facepp/v3/detect',
{
'Content-Type': 'multipart/form-data',
'api_key': self.key,
'api_secret': self.secret,
'image_base64': img_file,
'return_attributes': 'gender,age,headpose,facequality,eyestatus,emotion,ethnicity,beauty,mouthstatus'
}
)
result = response.json()
return result["faces"][0]["attributes"]["beauty"]["female_score"]
if __name__ == '__main__':
key = "API token"
secret = "API secret"
fp = FacePlus(key, secret)
print(fp.judge_face("test.jpeg "))
#Works with tinder's auto-like Notes ・ For those who have multiple photos, refer to the first one. -It is necessary to create a tmp folder, and the photo data will be saved in the tmp folder. -Adjust the like threshold by changing the score of the if statement of score. ・ Try,Use the except sentence to repel photos that do not have a face photo.
import requests
import json
import os
from tinder_token.facebook import TinderTokenFacebookV2
import urllib.error
import urllib.request
import faceplus
facebook = TinderTokenFacebookV2()
key = "face++_api"
secret = "face++_api_secret"
mail = "facebook_mail"
password = "facebook_password"
border = 75
fp = faceplus.FacePlus(key,secret)
def sample_email_password(email: str, password: str) -> (str, str):
return facebook.get_tinder_token(fb_email=email, fb_password=password)
def download_file(url, dst_path):
try:
with urllib.request.urlopen(url) as web_file:
data = web_file.read()
with open(dst_path, mode='wb') as local_file:
local_file.write(data)
except urllib.error.URLError as e:
print(e)
def download_file_to_dir(url, dst_dir):
download_file(url, os.path.join(dst_dir, os.path.basename(url)))
# Get Tinder Token
api_token = sample_email_password(mail,password)[0]
s = requests.Session()
# Log in to Tinder
headers = {"X-Auth-Token": api_token, "Content-type": "application/json",
"User-agent": "Tinder/10.1.0 (iPhone; iOS 12.1; Scale/2.00)"}
s.headers.update(headers)
meta = s.get("https://api.gotinder.com/meta")
print(meta.text)
endpoint = "v2/meta"
# Latitude and longitude of Shibuya
latitude = 35.658034
longitude = 139.701636
params = {"lat": latitude, "lon": longitude}
url = "https://api.gotinder.com/" + endpoint
response = s.post(url, data=json.dumps(params))
limit = 10
params = {"limit": limit}
name_list = []
for i in range(3):
users=s.post("https://api.gotinder.com/user/recs", data=json.dumps(params))
content = users.content
if len(content) > 0:
content = content.decode("utf-8")
content = json.loads(content)
else:
break
#print(content)
for user in content["results"]:
#print(user)
print(user["name"])
id = user["_id"]
name_list.append(user["name"])
photo = user['photos'][0]
Create a #tmp file
dst_dir = 'tmp/'
print(photo['url'])
#Save file
download_file_to_dir(photo['url'], dst_dir)
f_name = photo['url'].split('/')[-1]
print(f_name)
try:
score = fp.judge_face("./tmp/"+f_name)
print(score)
if(score >= border):
#Right swipe
s.get("https://api.gotinder.com/like/{}".format(id))
except:
print("error")
#Summary Although it was good to make, I was satisfied when it was completed and I couldn't do the demonstration experiment after all. It's a bad thing about engineers whose purpose changes on the way.(Lol)。
Follow the rules and have a fun tinder life!
#References
[1]https://qiita.com/Fulltea/items/fe4d4214552476c28e88 [2]https://note.com/ryohei55/n/n72084219f751
Recommended Posts