Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
自动like探探上的所有人
#-*-coding:utf-8-*-
import hashlib
import hmac
import time
import requests
HMAC_KEY = '5tT!TQkf5fYbabw5?KL2659XgL^JgxWw8r9Y+bAvGwP-QfteQL'
class TanTan(object):
base_url = 'https://core.tantanapp.com'
def __init__(self, auth_token, geo_lat, geo_lon):
self.auth_token = auth_token
self.geo_lat = geo_lat
self.geo_lon = geo_lon
def request(self, method, endpoint, **kwargs):
url = self.base_url + endpoint
headers = kwargs.pop('headers', {})
headers.update(self.get_default_headers())
r = requests.request(method, url, headers=headers, **kwargs)
data = r.json()
if data['meta'].get('code') != 200:
raise RuntimeError(data)
else:
return data
def get_default_headers(self):
return {
'Geolocation': 'geo:{self.geo_lat},{self.geo_lon};u=65'.format(self=self),
'User-Agent': 'Putong/2.1.1.1 iOS/9.2.1 iPhone/iPhone8,1 (iPhone 6s)',
'Authorization': self.get_auth_string(),
}
def get_auth_string(self, timestamp=None):
if not timestamp:
timestamp = int(time.time())
message = '{timestamp}.{auth_token}'.format(
timestamp=timestamp, auth_token=self.auth_token
)
hmac_string = self.hmac_sha1(HMAC_KEY, message)
return 'MAC ["1","android1.7.1","{timestamp}","{auth_token}","{hmac}"]'.format(
timestamp=timestamp, auth_token=self.auth_token, hmac=hmac_string
)
@staticmethod
def hmac_sha1(key, message):
return hmac.new(key, message, hashlib.sha1).digest().encode('base64').strip()
def like(self, user_id):
endpoint = '/v1/users/me/relationships/{user_id}'.format(user_id=user_id)
return self.request('put', endpoint, json={'state': 'liked'})
def get_user_list(self):
data = self.request('get', '/v1/users', params={
'search': 'suggested',
'with': 'questions,contacts'
})
users = data['data']['users']
return users
def main():
tantan = TanTan('xxxxxxxxxxxxxxxx', 39.9724, 116.4861)
while True:
users = tantan.get_user_list()
for user in users:
print u'Like {id} - {name}'.format(**user)
tantan.like(user['id'])
time.sleep(0.5)
if __name__ == '__main__':
main()
@green23

This comment has been minimized.

Copy link

@green23 green23 commented Sep 29, 2016

请问HMAC_KEY是从哪里得到的?

@wong2

This comment has been minimized.

Copy link
Owner Author

@wong2 wong2 commented Oct 22, 2016

@green23 反编译app得到的

@prid

This comment has been minimized.

Copy link

@prid prid commented Mar 18, 2017

auth_token怎么拿到?

@ananas-xxj

This comment has been minimized.

Copy link

@ananas-xxj ananas-xxj commented Sep 25, 2017

探探应该加固了,我用jadx反编译过来 乱的很厉害,找不到逻辑。请问作者用的什么反编译探探,跪求回答,谢谢。

@acodercat

This comment has been minimized.

Copy link

@acodercat acodercat commented Dec 2, 2020

hey! i need your help.

@acodercat

This comment has been minimized.

Copy link

@acodercat acodercat commented Dec 2, 2020

可以留下联系方式吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment