def collect_to_pandas_dataframe_user(user): connexion = connect.twitter_setup() tweets = collect_by_user(user) data = pd.DataFrame(data=[tweet.text for tweet in tweets], columns=['tweet_textual_content']) data['len'] = np.array([len(tweet.text) for tweet in tweets]) data['ID'] = np.array([tweet.id for tweet in tweets]) data['Date'] = np.array([tweet.created_at for tweet in tweets]) data['Source'] = np.array([tweet.source for tweet in tweets]) data['Likes'] = np.array([tweet.favorite_count for tweet in tweets]) data['RTs'] = np.array([tweet.retweet_count for tweet in tweets]) return data
def collect_to_pandas_dataframe(): connexion = connect.twitter_setup() tweets = connexion.search("@EmmanuelMacron", language="fr", rpp=100) data = pd.DataFrame(data=[tweet.text for tweet in tweets], columns=['tweet_textual_content']) data['len'] = np.array([len(tweet.text) for tweet in tweets]) data['ID'] = np.array([tweet.id for tweet in tweets]) data['Date'] = np.array([tweet.created_at for tweet in tweets]) data['Source'] = np.array([tweet.source for tweet in tweets]) data['Likes'] = np.array([tweet.favorite_count for tweet in tweets]) data['RTs'] = np.array([tweet.retweet_count for tweet in tweets]) return data
def collect_by_user(user_id): connexion = connect.twitter_setup() statuses = connexion.user_timeline(id=user_id, count=10) for status in statuses: print(status.text) return statuses
def collect(): connexion = connect.twitter_setup() tweets = connexion.search("Emmanuel Macron", language="french", rpp=1) for tweet in tweets: print(tweet.text)
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 = 100) return statuses