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.
Prerequisite framework
1.INSTALL tweepy
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 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)
#####example
# 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
lang=”en”,
since=”2019-03-01″).items():
print (tweet.created_at, tweet.csv)
csvWriter.writerow([tweet.created_at, tweet.text.encode(‘utf-8’)])
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.
1 comment
Hey there I read this article fully concerning the difference of most up-to-date and preceding technologies, it’s amazing article. grazie
Comments are closed.