我一直在尝试让这个脚本输出一系列状态实例。我想将文本输出保存到文件中,这可能吗?有谁知道我错过了什么?
提前致谢! :)
api = twitter.Api(consumer_key='int',
consumer_secret='int',
access_token_key='int',
access_token_secret='int')
def GetUserTimeline(self,
user_id=111554559,
screen_name='Enhedslisten',
since_id=None,
max_id=783373235568214016,
count=200,
include_rts=True,
trim_user=True,
exclude_replies=True):
url = '%s/statuses/user_timeline.json' % (self.base_url)
parameters = {}
if user_id:
parameters['user_id'] = enf_type('user_id', int, user_id)
elif screen_name:
parameters['screen_name'] = screen_name
if since_id:
parameters['since_id'] = enf_type('since_id', int, since_id)
if max_id:
parameters['max_id'] = enf_type('max_id', int, max_id)
if count:
parameters['count'] = enf_type('count', int, count)
parameters['include_rts'] = enf_type('include_rts', bool, include_rts)
parameters['trim_user'] = enf_type('trim_user', bool, trim_user)
parameters['exclude_replies'] = enf_type('exclude_replies', bool, exclude_replies)
resp = self._RequestUrl(url, 'GET', data=parameters)
data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
return [Status.NewFromJsonDict(x) for x in data]