MCPcopy Create free account
hub / github.com/LumingMelody/JS_reverse / parse_response

Function parse_response

twitter.py:145–176  ·  view source on GitHub ↗
(twitter_content)

Source from the content-addressed store, hash-verified

143
144
145def parse_response(twitter_content):
146 instructionList = twitter_content['data']['user']['result']['timeline']['timeline']['instructions']
147 cursor = None
148 instructions = None
149
150 for ins in instructionList:
151 if ins['type'] == 'TimelineAddEntries':
152 instructions = ins['entries']
153 break
154
155 for user_twitter in instructions:
156 if 'cursor-bottom' in user_twitter['entryId']:
157 cursor = user_twitter['content']['value']
158 if not user_twitter['content'].get('itemContent'):
159 continue
160 if not user_twitter['content']['itemContent'].get('tweet_results'):
161 logger.debug("所有推文获取完毕")
162 break
163 legacy = user_twitter['content']['itemContent']['tweet_results']['result'].get('legacy')
164 if not legacy: continue
165 full_text = legacy['full_text']
166 lang = legacy['lang']
167 quote_count = legacy['quote_count'] # 引用
168 favorite_count = legacy['favorite_count'] # 喜欢
169 reply_count = legacy['reply_count'] # 回复
170 retweet_count = legacy['retweet_count'] # 转推
171 id_str = legacy['id_str']
172 created_at = legacy['created_at']
173 print(id_str, full_text[:50])
174
175 logger.debug(f"下一页cursor:{cursor}")
176 return cursor
177
178
179if __name__ == '__main__':

Callers 1

requestTWFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected