def get_retweets_of_candidate(num_candidate):
    try:
        total_replies = []
        connexion = connect.twitter_setup()
        statuses = connexion.user_timeline(id=num_candidate, count=200)
        for status in statuses:
            id_status = status.id
            replies = connexion.search("Macron",
                                       in_reply_to_status_id_str=id_status,
                                       language="french",
                                       rpp=1)
            for reply in replies:
                if reply.text not in total_replies:
                    total_replies.append(reply.text)
                    print(reply.text)
        return total_replies
    except tweepy.error.RateLimitError:
        print("Limite de stream de tweet atteinte, revient dans 1h")
Example #2
0
def collect_by_streaming():

    connexion = connect.twitter_setup()
    listener = StdOutListener()
    stream = tweepy.Stream(auth=connexion.auth, listener=listener)
    stream.filter(track=['Emmanuel Macron'])
def collect_by_user(user_id):
    connexion = connect.twitter_setup()
    statuses = connexion.user_timeline(id=user_id, count=200)
    for status in statuses:
        print(status.text)
    return statuses
Example #4
0
def collect(keyword):
    connexion = connect.twitter_setup()
    tweets = connexion.search(keyword, language="french", rpp=1)
    #for tweet in tweets:
    #    print(tweet.text)
    return (tweets)