forked from xjr7670/QQzone_crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_qq_number.py
31 lines (25 loc) · 1.03 KB
/
get_qq_number.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
import json
import os
class exact_data_from_result(object):
'''Define method to get my qq friends data from result
and get my mood data from result'''
def __init__(self):
print("Start to exact the qq number item from get_friends result")
def exact_qq_number(self):
'''Get qq number data from json file'''
friendsFiles = [x for x in os.listdir('friends') if x.endswith("json")]
qqnumber_item = []
i = 0
for each_file in friendsFiles:
with open('friends/' + each_file) as f:
source = f.read()
con_dict = source[75:-4].replace('\n', '')
con_json = json.loads(con_dict)
friends_list = con_json['uinlist']
# Get each item from friends list, each item is a dict
for item in friends_list:
i = i + 1
qqnumber_item.append(item)
else:
with open('qqnumber.inc', 'w') as qqfile:
qqfile.write(str(qqnumber_item))