Twitter Twint Scanner

Twitter Twint Scanner
Photo by Alexander Shatov / Unsplash

In this experiment i will be writing a script that imports the Twint plugin that enables you to scan Twitter without the use of an API.

The script will prompt the user for some basic keywords then it will scrape twitter and return results within the terminal. First off we need to import a few modules in our script, pyfiglet and Twint !

Pyfiglet will enable you to create a nice little banner when you run the script, to install this module run the following command in your terminal

pip install pyfiglet==0.7

Within the script you will need to tell pyfiglet to create that fancy text, you can do this by typing the following

ascii_banner = pyfiglet.figlet_format("Twitter Scan")print(ascii_banner)

This piece of code will produce an ASCII banner that shows TWITTER SCAN just like the below image

There are many different styles you can choose, more can be found on the github page for this project https://github.com/pwaller/pyfiglet

After that we need to import TWINT, there may be aditional requirements you need to get this plugin working thankfully they are listed within a text file in the repository called " requirements.txt" .

Within your terminal  run the following commands

git clone --depth=1 https://github.com/twintproject/twint.git

This will clone the projeject to your laptop, change into the twint directory

cd twint

Then run the following to install the requirements for the plugin to work

pip3 install . -r requirements.txt

After you have the plugins installed you can then start to write the rest of the code and surprisingly you dont have to write that much of it. This example will allow you to search for a particular word mentioned within a specific region.

The plugin enables you to search for a whole host of criteria, you can see from the above image the twint plugin has particular values you can call they all start with "c." if you use a popular IDE to write your code it should start to populate with some different values you can search from ( Search, Near,Limit,Popular_tweets,) .

When you have added what you would like to search the script can then call the plugin to retrieve the results. The python script has a user input for two questions and as you can see the "input" presents two questions " What and Where"

The above shows the output from the search we performed " Apple and California" the script will then end showing you the limit of 20 tweets. What if we wanted to output this information into a document such as JSON ? Well you can do that by adding " c.store_json = True" this will create the document output then you will need to give that document a name " c.Output = "tweets.json" .

From this output you can then manipulate the data and create websites or charts tracking particular phrases or keywords. There are many more fun things you can do with Twint, this small writeup explains just the tip of the iceberg!

Resources for this blog :

GitHub - twintproject/twint: An advanced Twitter scraping & OSINT tool written in Python that doesn’t use Twitter’s API, allowing you to scrape a user’s followers, following, Tweets and more while evading most API limitations.
An advanced Twitter scraping & OSINT tool written in Python that doesn't use Twitter's API, allowing you to scrape a user's followers, following, Tweets and more while evading most ...
GitHub - pwaller/pyfiglet: An implementation of figlet written in Python
An implementation of figlet written in Python. Contribute to pwaller/pyfiglet development by creating an account on GitHub.
GitHub - Stratuscodelab/Twitter-Scan: Twitter Scan using Twint to perform a simple search of keywords on twitter without an API, location can be used also.
Twitter Scan using Twint to perform a simple search of keywords on twitter without an API, location can be used also. - GitHub - Stratuscodelab/Twitter-Scan: Twitter Scan using Twint to perform a s...