trusted_source_extractor.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:aihackathon 作者: nicoheidtke 项目源码 文件源码
def extract_tweets_from_a_source(self, source):
        if '@' not in source:
            source = '@' + source

        extracted_tweets = []
        try:
            print "Extracting %s..." % source
            max_twitter_id = None
            while True:
                tw = self.API.user_timeline(screen_name=source, count=self.N_TWEETS_PER_REQUEST, max_id=max_twitter_id)
                if not len(tw):
                    break

                extracted_tweets += [self.get_filtered_tweet(t) for t in tw]
                earliest_tweet_date = extracted_tweets[-1]['created_at']
                if earliest_tweet_date < self.from_time:
                    break

                max_twitter_id = extracted_tweets[-1]['id'] - 1
        except TweepError:
            print "Error processing", source

        print "\textracted %d tweets for %s" % (len(extracted_tweets), source)
        self.TWEET_STORAGE += extracted_tweets
        return extracted_tweets
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号