-
-
Save sxshateri/540aead254bfa7810ee8bbb2d298363e to your computer and use it in GitHub Desktop.
import tweepy | |
import csv | |
import pandas as pd | |
import sys | |
# API credentials here | |
consumer_key = 'INSERT CONSUMER KEY HERE' | |
consumer_secret = 'INSERT CONSUMER SECRET HERE' | |
access_token = 'INSERT ACCESS TOKEN HERE' | |
access_token_secret = 'INSERT ACCESS TOKEN SECRET HERE' | |
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,wait_on_rate_limit_notify=True) | |
# Search word/hashtag value | |
HashValue = "" | |
# search start date value. the search will start from this date to the current date. | |
StartDate = "" | |
# getting the search word/hashtag and date range from user | |
HashValue = input("Enter the hashtag you want the tweets to be downloaded for: ") | |
StartDate = input("Enter the start date in this format yyyy-mm-dd: ") | |
# Open/Create a file to append data | |
csvFile = open(HashValue+'.csv', 'a') | |
#Use csv Writer | |
csvWriter = csv.writer(csvFile) | |
for tweet in tweepy.Cursor(api.search,q=HashValue,count=20,lang="en",since=StartDate, tweet_mode='extended').items(): | |
print (tweet.created_at, tweet.full_text) | |
csvWriter.writerow([tweet.created_at, tweet.full_text.encode('utf-8')]) | |
print ("Scraping finished and saved to "+HashValue+".csv") | |
#sys.exit() |
dhilataha
commented
Dec 1, 2020
via email
I runs the program in google colaboratory then i dont know where is my #hashtag.csv file. I search it all over my computer's document but i cant find it Heavenly Regard Fadhillah Putri Taha Pada tanggal Sel, 1 Des 2020 08.14, Shahin Shateri [email protected] menulis:
…
@.**** commented on this gist. ------------------------------ where is the file of tweets i downloaded? @dhilataha https://github.com/dhilataha where ever your script file is will be a .csv file with the same name as the hashtag you entered. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://gist.github.com/540aead254bfa7810ee8bbb2d298363e#gistcomment-3545483, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2ZFBY44FON34QYWCRDTBDSSQYOZANCNFSM4HYAEFAA .
I have this same issue.. did you ever find it?