Пример #1
0
def _fetch_and_parse_twitter():
    try:
        auth = tweepy.OAuthHandler(settings.TWITTER_CONSUMER_KEY,
                                   settings.TWITTER_CONSUMER_SECRET)
        auth.set_access_token(settings.TWITTER_ACCESS_TOKEN,
                              settings.TWITTER_ACCESS_TOKEN_SECRET)
        twitter_api = tweepy.API(auth)
        tweets = twitter_api.user_timeline('samuelclay',
                                           exclude_replies=True,
                                           count=100,
                                           trim_user=True,
                                           include_rts=False)
    except tweepy.TweepError:
        return []

    # shown_tweets = [t for t in tweets if not t.text.startswith('@')]
    fixed_tweets = []
    for tweet in tweets[:12]:
        fixed_tweets.append({
            'relative_created_at':
            "%s ago" % relative_timesince(tweet.created_at),
            'text':
            tweet.text,
            'id':
            tweet.id,
        })

    return fixed_tweets
Пример #2
0
def _fetch_and_parse_twitter():
    try:
        twitter_api = tweepy.API()
        tweets = twitter_api.user_timeline('samuelclay', exclude_replies=True, 
                                           count=100, trim_user=True, include_rts=False)
    except tweepy.TweepError:
        return []
        
    # shown_tweets = [t for t in tweets if not t.text.startswith('@')]
    fixed_tweets = []
    for tweet in tweets[:12]:
        fixed_tweets.append({
            'relative_created_at': "%s ago" % relative_timesince(tweet.created_at),
            'text': tweet.text,
        })

    return fixed_tweets
Пример #3
0
def _fetch_and_parse_twitter():
    try:
        auth = tweepy.OAuthHandler(settings.TWITTER_CONSUMER_KEY, settings.TWITTER_CONSUMER_SECRET)
        auth.set_access_token(settings.TWITTER_ACCESS_TOKEN, settings.TWITTER_ACCESS_TOKEN_SECRET)
        twitter_api = tweepy.API(auth)
        tweets = twitter_api.user_timeline('samuelclay', exclude_replies=True, 
                                           count=100, trim_user=True, include_rts=False)
    except tweepy.TweepError:
        return []
        
    # shown_tweets = [t for t in tweets if not t.text.startswith('@')]
    fixed_tweets = []
    for tweet in tweets[:12]:
        fixed_tweets.append({
            'relative_created_at': "%s ago" % relative_timesince(tweet.created_at),
            'text': tweet.text,
            'id': tweet.id,
        })

    return fixed_tweets