本文整理汇总了Python中twitter.Twitter.get_user_timeline方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter.get_user_timeline方法的具体用法?Python Twitter.get_user_timeline怎么用?Python Twitter.get_user_timeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.Twitter
的用法示例。
在下文中一共展示了Twitter.get_user_timeline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_timeline
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import get_user_timeline [as 别名]
def test_get_timeline(self):
t = Twitter(**twitter_access)
user = twitter_username
count = 6
output = t.get_user_timeline(user=user, count=count)
resp_user = set([i['user']['screen_name'] for i in output])
# Set the ID for latest tweet before tests
_write_top_tweet_file(output[0]['id'])
self.assertEqual(1, len(resp_user))
self.assertEqual(user, list(resp_user)[0])
self.assertEqual(count, len(output))
示例2: test_delete_tweet
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import get_user_timeline [as 别名]
def test_delete_tweet(self):
"""
Test deletion of tweets.
Use the above tweets for deletion with the help of tweet_list
:return:
:rtype:
"""
t = Twitter(**twitter_access)
# Get current latest tweet ID
latest_tweet = t.get_user_timeline(user=twitter_username, count=1)
latest_tweet_id = latest_tweet[0].get('id')
self.assertNotEqual(latest_tweet_id, _read_id_top_tweet())
# Delete all test tweets
for tweet_id in _get_test_tweets():
output = t.delete_tweet(tweet_id=tweet_id)
self.assertEqual(tweet_id, output.get('id'))
# Get lates tweet ID after deletion
latest_tweet = t.get_user_timeline(user=twitter_username, count=1)
latest_tweet_id = latest_tweet[0].get('id')
self.assertEqual(latest_tweet_id, _read_id_top_tweet())
示例3: main
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import get_user_timeline [as 别名]
def main():
screen_name = 'boyakinushi'
twitter = Twitter()
paths = ['..', '..', 'local_data', 'twitter_cli']
twitter.set_cache_dir(os.path.join(*paths))
twitter.set_callback(print_to_console)
paths = ['..', '..', 'local_data', 'twitter_cli', 'config.ini']
twitter.load_ini_file(os.path.join(*paths))
print_to_console("Start")
# Show Twitter API Rate Limit
twitter.check_api_rate_limit()
# Home TimeLine.
tweets = twitter.get_home_timeline(100)
twitter.save_tweet_users(tweets)
twitter.save_tweets(tweets)
# User TimeLine.
tweets = twitter.get_user_timeline(screen_name, 100)
twitter.save_tweet_users(tweets)
twitter.save_tweets(tweets)