1import tweepy
2consumer_key= 'your consumer_key'
3consumer_secret= 'your consumer_key_secret'
4access_token= 'your access_token'
5access_token_secret= 'your access_token_secret'
6auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
7auth.set_access_token(access_token,access_token_secret)
8api = tweepy.API(auth)
9#From here, you can tweet, search tweets, search keywords, etc.
1import os
2import tweepy as tw
3import pandas as pd
4
5consumer_key= 'yourkeyhere'
6consumer_secret= 'yourkeyhere'
7access_token= 'yourkeyhere'
8access_token_secret= 'yourkeyhere'
9auth = tw.OAuthHandler(consumer_key, consumer_secret)
10auth.set_access_token(access_token, access_token_secret)
11api = tw.API(auth, wait_on_rate_limit=True)
12# Post a tweet from Python
13api.update_status("Look, I'm tweeting from #Python in my #earthanalytics class! @EarthLabCU")
14# Your tweet has been posted!
15# Define the search term and the date_since date as variables
16search_words = "#wildfires"
17date_since = "2018-11-16"
18# Collect tweets
19tweets = tw.Cursor(api.search,
20 q=search_words,
21 lang="en",
22 since=date_since).items(5)
23# Collect tweets
24tweets = tw.Cursor(api.search,
25 q=search_words,
26 lang="en",
27 since=date_since).items(5)
28
29# Iterate and print tweets
30for tweet in tweets:
31 print(tweet.text)
32# Collect tweets
33tweets = tw.Cursor(api.search,
34 q=search_words,
35 lang="en",
36 since=date_since).items(5)
37
38# Collect a list of tweets
39[tweet.text for tweet in tweets]