If you write TinderBot in Python, she can do it

Introduction

There was such a bash script in gist. If you launch Tinder on Android and run it, it seems that you can just keep swiping to the right (: heart :).

while true; do
    ./adb shell input swipe 100 400 4000 400 400;
done

https://gist.github.com/lawloretienne/4f044bde3eb8de67e2ae

How simple it is! be moved. I decided to start Tinder right away. But Tinder has a swipe limit, he said. If a free user swipes about 120 times, he will not be able to swipe for a certain period of time. This restriction seems to be removed by registering for paid adultery. About 1000 yen a month. Tomorrow is a petite fast.

TinderBot

The gist above is simple and nice. Nobody thinks that even if you play this at work, you're messing around with Tinder. Just like a ninja.

But this doesn't tell you what kind of people are in Tinder and who you are: heart :. It's Tom DeMarco's maxim that "what you can't measure can't be controlled", and it's no exaggeration to say that if you can't control the women who flock to me (of course, that's the case), it's a shame for a man. Then what should we do.

Just hit the API. It was easy to come up with. It's far from the simplicity of gist above, but I found a client for Python that I'm familiar with, so I first wrote a bot that saves the information of the person who swiped 10,000 times in SQLite.

Preparatory movement

My environment is Ubuntu 14.04 LTS, so I have to prepare a little. What a big deal.

$ sudo apt-get install build-essential python-dev libffi-dev libssl-dev
$ pip install pyopenssl ndg-httpsclient pyasn1 requests[security] python-datetimeutil SQLAlchemy

Next, get your Facebook user ID and access token.

User ID is this site http://findmyfbid.com/

The access token can now be issued. You just have to copy the URL from the address bar before being redirected. The access token is embedded in the GET parameter of the URL. It is said that this token will disappear in a short time (1 to 2 hours). https://www.facebook.com/dialog/oauth?client_id=464891386855067&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=basic_info,email,public_profile,user_about_me,user_activities,user_birthday,user_education_history,user_friends,user_interests,user_likes,user_location,user_photos,user_relationship_details&response_type=token

: heart: => 10,000 girls

If it's real, even one person is quite prepared to do: heart :, but with Tinder, 10,000 people can do: heart:. By the way, at this point, we are charging and removing the restrictions on the area and age. Distance and age difference are not related to romance. By the way, it takes the longest time to think about the profile sentence so far.

from __future__ import unicode_literals
from datetime import datetime

from sqlalchemy import Column
from sqlalchemy import create_engine
from sqlalchemy import Date, DateTime
from sqlalchemy import Float, ForeignKey
from sqlalchemy import Integer
from sqlalchemy import SmallInteger
from sqlalchemy import String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.orm import sessionmaker

import pynder

FBTOKEN = 'Facebook tokens I got'
FBID = 'I got my Facebook ID'

engine = create_engine('sqlite:///tinder.sqlite3', echo=True)
Session = sessionmaker(bind=engine)
Base = declarative_base()


class User(Base):
    __tablename__ = 'users'

    id = Column(Integer, primary_key=True)
    name = Column(String)
    bio = Column(String)
    age = Column(SmallInteger)
    birth_date = Column(Date)
    ping_time = Column(DateTime)
    distance_km = Column(Float)
    get_photos = relationship('Photo')
    schools = relationship('School')
    jobs = relationship('Job')


class Photo(Base):
    __tablename__ = 'photos'

    id = Column(Integer, primary_key=True)
    user_id = Column(Integer, ForeignKey('users.id'))
    url = Column(String)


class School(Base):
    __tablename__ = 'schools'

    id = Column(Integer, primary_key=True)
    user_id = Column(Integer, ForeignKey('users.id'))
    name = Column(String)


class Job(Base):
    __tablename__ = 'jobs'

    id = Column(Integer, primary_key=True)
    user_id = Column(Integer, ForeignKey('users.id'))
    name = Column(String)


def like_tinder_users(limit):
    sql_session = Session()

    session = pynder.Session(FBID, FBTOKEN)
    nearby_users = session.nearby_users(limit)[:limit]

    for user in nearby_users:
        photos = [Photo(url=url) for url in user.get_photos(width='640')]
        schools = [School(name=name) for name in user.schools]
        jobs = [Job(name=name) for name in user.jobs]

        sql_user = User(
            name=user.name,
            bio=user.bio,
            age=user.age,
            birth_date=user.birth_date,
            ping_time=datetime.strptime(user.ping_time, '%Y-%m-%dT%H:%M:%S.%fZ'),
            distance_km=user.distance_km,
            get_photos=photos,
            schools=schools,
            jobs=jobs,
        )
        sql_session.add(sql_user)
        user.like()

    sql_session.commit()
    sql_session.close()

if __name__ == '__main__':
    Base.metadata.create_all(engine)
    for i in range(1, 1001):
        like_tinder_users(10)
        print('I liked {} women xD'.format(i * 10))

Actually, I wrote the code to automate authentication with Selenium + phantomjs, so I have not confirmed the operation, but it seems like this.

Column-Desktop version of Tinder

I feel that the character input speed of Android is only about 10% faster than that when using the keyboard. In other words, if you match a lot of women, character input can become a bottleneck. Many dating services have a web version, so it doesn't matter, but Tinder doesn't have a web version. So I decided to get the help of my predecessor again.

It's an unofficial desktop version. It is made with NW.js instead of the recently popular Electron. But there is no Linux version? Don't worry. Just change the build file a bit. Fortunately, there was a person who made this patch. I cloned each master and rewrote it according to diff, and it worked perfectly with Trusty. It's selfish, and I'm prepared to do it.

Visualization

No matter how much data you put in the DB, it makes no sense if you don't know the breakdown. I want to quickly display nice data with seaborn. But at the moment, the match is 0.15% (still 0.05% better than when I first posted it), and when I thought the woman talked to me, it was Amway (), so I'm going to sleep a little longer. On weekends, I would like to take on the challenge of visualization while I am busy with a tour of facilities of new religions and a briefing session on Amway / antiquities.

Recommended Posts

If you write TinderBot in Python, she can do it
If you guys in the scope kitchen can do it with a margin ~ ♪
Why do you add a main ()-if statement in Python?
Python | What you can do with Python
Don't write Python if you want to speed it up with Python
What to do if you get a minus zero in Python
Check if you can connect to a TCP port in Python
If you write go table driven test in python, it may be better to use subTest
What to do if you can't use scikit grid search in Python
You can do it with Python! Structural analysis of two-dimensional colloidal crystals
What happens if you do "import A, B as C" in Python?
You will be an engineer in 100 days --Day 35 --Python --What you can do with Python
If you know this much, you can write Python test code! ~ Super introductory edition ~
What to do if you get "Python not configured." Using PyDev in Eclipse
Is Parallel Programming Hard, And, If So, What Can You Do About It?
Write Python in MySQL
% And str.format () in Python. Which one do you use?
If you encounter a "Unicode Decode Error" in Python
Consideration when you can do a good job in 10 years with Python3 and Scala3.
What to do if you get `No kernel for language python found` in Hydrogen
What to do if you get an error when importing matplotlib in Python (Mac)
You can do it in 3 minutes! How to make a moving QR code (GIF)!
Understand Python yield If you put yield in a function, it will change to a generator
What to do if you can't hit the arrow keys in the Python interactive console
What to do if you run python in IntelliJ and end with an error
[For beginners] You can do it from scratch! Creating APIs with AWS SAM and outputting OpenAPI documentation in Python
If you don't understand mathematical symbols, you can write a program.
Write Pandoc filters in Python
Let's recommend Malbolge to those who say "If you do one programming language, you can do it"
[Python version] Why can't you do object-oriented development in Java?
Write beta distribution in Python
Write python in Rstudio (reticulate)
[Python] How to write an if statement in one sentence.
What you can do with the Python standard library statistics
What to do if you get "coverage unknown" in Coveralls
What to do if you get Swagger-codegen in python and Import Error: No module named
What to do if you can't log in as root
Here are some grammars that you might get a slapstick face if you know it in Python
Do you want to wait for general purpose in Python Selenium?
It seems that you can now write gate books with blueqat
If you get stuck in Cannot load mkl_intel_thread.dll in Python on Windows
What to do if you can't install pyaudio with pip #Python
Delete a particular character in Python if it is the last
Difference in how to write if statement between ruby ​​and python
Consider what you can do with Python from the Qiita article
If you want to assign csv export to a variable in python
What to do if you can't use the trash in Lubuntu 18.04.
[Python] How to do PCA in Python
Write JSON Schema in Python DSL
Do you need a Python re.compile?
Write an HTTP / 2 server in Python
Until you put Python in Docker
Write AWS Lambda function in Python
Write A * (A-star) algorithm in Python
Write selenium test code in python
Write a pie chart in Python
Write a vim plugin in Python
Write a depth-first search in Python
Write C unit tests in Python
What to do if you get angry with "Value Error: unknown local: UTF-8" in python manage.py syncdb
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda