-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.py
executable file
·70 lines (53 loc) · 2.04 KB
/
search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
import json
import os
import sys
import random
import requests
import skpy
class SkypeSearch:
def __init__(self, token):
self.skype_token = token
self.session = requests.session()
self.session.headers.update({
"X-Skypetoken": self.skype_token,
"X-ECS-ETag": "Fzn/9gnnfHwbTYyoLcWa1FhbSVkgRg28SzNJqolgQHg=",
"X-Skype-Client": "1419/8.26.0.70",
"X-SkypeGraphServiceSettings": '{"experiment":"MinimumFriendsForAnnotationsEnabled","geoProximity":"disabled","minimumFriendsForAnnotationsEnabled":"true","minimumFriendsForAnnotations":2,"demotionScoreEnabled":"true"}',
'accept-encoding': 'gzip',
'user-agent': 'okhttp/3.10.0',
})
def search(self, search_query):
params = {
"searchString": search_query,
"requestId": random.randint(1e13, 9e13)
}
search_response = self.session.get("https://skypegraph.skype.com/v2.0/search", params = params)
if search_response.status_code == 200:
json_response = search_response.json()
relevant_data = json_response["results"]
output = []
for info in relevant_data:
output.append(info["nodeProfileData"])
return output
return []
def extract():
if len(sys.argv) == 1:
term = input('Input phone (or something other) for Skype contact search: ')
else:
term = sys.argv[1]
sk = None
token_file = './tokens.txt'
if os.path.exists(token_file):
sk = skpy.Skype(connect=False)
sk.conn.tokenFile = token_file
sk.conn.readToken()
if not sk or not sk.conn.tokens:
login = os.getenv('SKYPE_LOGIN') or input('Login: ')
passw = os.getenv('SKYPE_PASS') or input('Password: ')
sk = skpy.Skype(login, passw, token_file)
search = SkypeSearch(token=sk.conn.tokens['skype'])
res = search.search(search_query=term)
print(json.dumps(res, indent=4))
if __name__ == '__main__':
extract()