Well if you are a beginner in Ethical hacking you would probably find it difficult to have a ready-made script to execute, for finding out the tweets with a particular hashtag.
It’s a tough job and can take a lot of time to get all the required results. So, just have a quick look at how we can really do this job in a matter of seconds with some little adjustment in the script.
Python script for download tweets with specified hashtag in csv file
- First of all create a twitter developer account: https://developer.twitter.com/
2. After successful account verification create your first app and collect
comsumer_key, consumer_secret, access_token, access_token_secret
3.Set all your keys in python script.
4. Replace #example to your specified #hashtag in line 21.
5.Before you run the script in terminal install some prerequisite framework.
In your terminal type: pip install tweepy (kali linux)
2. INSTALL pandas
In your terminal type: pip install pandas/panda
Use pandas our panda
3. INSTALL pd
In your terminal type: pip install pd
After the install all framework run your .py script in terminal
Type in your terminal python tweetdx.py
After your success, a .csv file created in your storage with all of the tweets with the hashtag
Just copy and save this Python script in your system and run it in your terminal.
import pandas as pd
####input your credentials here
consumer_key = ”
consumer_secret = ”
access_token = ”
access_token_secret = ”
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
api = tweepy.API(auth,wait_on_rate_limit=True)
# Open/Create a file to append data
csvFile = open(‘avii.csv’, ‘a’)
#Use csv Writer
csvWriter = csv.writer(csvFile)
for tweet in tweepy.Cursor(api.search,q=”#example”,count=100,
#replace example to your specified #hashtag
print (tweet.created_at, tweet.csv)
And you are all done with a .csv file having a list of all tweets posted on tweeter with any particular hashtag. if you have any problem while running the script you can always contact us.