-
-
Save vickyqian/f70e9ab3910c7c290d9d715491cde44c to your computer and use it in GitHub Desktop.
import tweepy | |
import csv | |
import pandas as pd | |
####input your credentials here | |
consumer_key = '' | |
consumer_secret = '' | |
access_token = '' | |
access_token_secret = '' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth,wait_on_rate_limit=True) | |
#####United Airlines | |
# Open/Create a file to append data | |
csvFile = open('ua.csv', 'a') | |
#Use csv Writer | |
csvWriter = csv.writer(csvFile) | |
for tweet in tweepy.Cursor(api.search,q="#unitedAIRLINES",count=100, | |
lang="en", | |
since="2017-04-03").items(): | |
print (tweet.created_at, tweet.text) | |
csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')]) |
Many thanks for the crawler mate, I was looking for it and didn´t have time to spend on it.
cheers
I get This error from Python :
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 22-23: truncated \UXXXXXXXX escape
Any help please !!
Hello,
how we can add the geolocalisation like : France to this script and more filters in the search ???
AttributeError Traceback (most recent call last)
C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_11192/3895188609.py in
19 #Use csv Writer
20 csvWriter = csv.writer(csvFile)
---> 21 for tweet in tweepy.Cursor(api.search, q="#unitedAIRLINES",count=100, lang="en", since="2021-09-14").items():
22 print (tweet.created_at, tweet.text)
23 csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])
AttributeError: 'API' object has no attribute 'search'
I am using the latest version of Anaconda Navigator 2.10 and jupyter Notebook 6.4.4.
I have regenerated API tokens. How do should I fix this?
AttributeError Traceback (most recent call last) C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_11192/3895188609.py in 19 #Use csv Writer 20 csvWriter = csv.writer(csvFile) ---> 21 for tweet in tweepy.Cursor(api.search, q="#unitedAIRLINES",count=100, lang="en", since="2021-09-14").items(): 22 print (tweet.created_at, tweet.text) 23 csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])
AttributeError: 'API' object has no attribute 'search'
I am using the latest version of Anaconda Navigator 2.10 and jupyter Notebook 6.4.4.
I have regenerated API tokens. How do should I fix this?
I am getting the exact error reported above.
I had to upgrade my version of Anaconda and then installed tweepy version 4.1.0 and from there the following command is not working for me:
tweepy.Cursor(api.search, q=ht, since=since_date_str).items()
Any idea how to solve it? do I have to go back to a previous version of tweepy? if so, which version?
@riiyasharmaa you might need to unindent (tab to the left)