MCPcopy
hub / github.com/nghuyong/WeiboSpider / parse_user_info

Function parse_user_info

weibospider/spiders/common.py:60–83  ·  view source on GitHub ↗

解析用户信息

(data)

Source from the content-addressed store, hash-verified

58
59
60def parse_user_info(data):
61 """
62 解析用户信息
63 """
64 # 基础信息
65 user = {
66 "_id": str(data['id']),
67 "avatar_hd": data['avatar_hd'],
68 "nick_name": data['screen_name'],
69 "verified": data['verified'],
70 }
71 # 额外的信息
72 keys = ['description', 'followers_count', 'friends_count', 'statuses_count',
73 'gender', 'location', 'mbrank', 'mbtype', 'credit_score']
74 for key in keys:
75 if key in data:
76 user[key] = data[key]
77 if 'created_at' in data:
78 user['created_at'] = parse_time(data.get('created_at'))
79 if user['verified']:
80 user['verified_type'] = data['verified_type']
81 if 'verified_reason' in data:
82 user['verified_reason'] = data['verified_reason']
83 return user
84
85
86def parse_tweet_info(data):

Callers 5

parseMethod · 0.90
parse_commentMethod · 0.90
parseMethod · 0.85
parseMethod · 0.85
parse_tweet_infoFunction · 0.85

Calls 1

parse_timeFunction · 0.85

Tested by

no test coverage detected