Created
March 28, 2020 06:13
-
-
Save satellitex/8a12aae65f85ee318e354a0e2c7e1445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import time | |
import sys | |
pdevice = "pc"; | |
pversion = "git--v20191107053409" | |
if len(sys.argv) == 2: | |
token = sys.argv[1] | |
else: | |
token = "~~~" | |
user_id = "~~~" | |
parameters = { | |
'search': { | |
'device': pdevice, | |
'limit': 128, | |
'offset': 0, | |
'search_type': 'search', | |
'version': pversion, | |
'without_communities': True, | |
}, | |
'user': { | |
'device': pdevice, | |
'version': pversion, | |
}, | |
'visitor': json.dumps({ | |
'device': pdevice, | |
'version': pversion, | |
}), | |
} | |
headers = { | |
'Pairs-Token': token, | |
'X-Pairs-User-ID': user_id, | |
'Content-Type': 'application/json', | |
} | |
def search(offset): | |
time.sleep(1); | |
r = requests.get('https://pairs.lv/1.0/user', params=parameters['search'], headers=headers) | |
print(r.status_code, flush=True) | |
res = json.loads(r.text) | |
return (res['here_page'], res['total_page'], res['instances']) | |
def footprint(id): | |
time.sleep(5); | |
url = 'https://pairs.lv/1.0/visitor/'+id | |
visitor = requests.post(url, data=json.dumps(parameters['user']), headers=headers) | |
print(visitor.status_code, flush=True) | |
if visitor.status_code != 201: | |
exit(0) | |
page = 0 | |
total = 0 | |
while True: | |
if page < total: | |
(page, total, instances) = search(page * parameters['search']['limit']) | |
else: | |
print('ReStart footpring', flush=True) | |
(page, total, instances) = search(0) | |
for ins in instances: | |
footprint(ins['id']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment