FNews – Automatic retrieval of latest security news and tweets

FNews – Automatic retrieval of latest security news and tweets


A few weeks ago, I wanted to keep myself abreast of all the latest hacking news in the world. I could not find a source where I could find every single news about security in one place. Then I had to do some work with twitter streaming API and this idea hit my mind that what if I write a script that does this job for me as well as for other people. This is how I got the idea of this little project and I am sharing it with you people below.

FNews – Automatic retrieval of latest hacking news and tweets

Get all the latest news about hacking and security in one place

We will be using twitter streaming API in this post with python as our programming language. The Twitter Streaming API lets us pull tweets related to certain topics live.

We’ll retrieve all the latest tweets about hacking. After that, we will prune and clean them and then save them in a file. That’s all we need to do and with such little work, we can set up our own news source which gives us all the latest news. Lets dive right in the code.

Set up your API keys that you get from twitter. Go to twitter API page to see how you can get your keys.

We need to create a StreamListener that will listen to all the incoming tweets. The main thing in this whole code was data cleaning. There was too much data that we were getting. The code is well commented and you can read how I have pruned the data.

Now we have set up our listener, all we have to do is create an instance of it and choose our keywords. We’ll use keywords related to hacking and breaches.
The choice of keywords depends on you. You can use this same script for any type of news or you can add your keywords. These were the keywords that just came into my mind and I added them.

That’s it. We have build a latest news source for all the hacking activities and news all around the world. Isn’t it amazing in how few lines we were able to do this.

Here are a few results with this script.

As we can see, these news are new. The adult friend finder one was just put on a few websites a few hours ago.

Machine Learning and Hacking:

Another great use case for this script is to find tweets that contain information about Machine Learning and Cyber Security.

This is a new field related to cyber security and there is not much stuff available on internet. I set up the script with keywords like “Machine Learning and Security”, “Data Science and Cyber Security” and I was able to get some very good stuff on this topic.

This is it from me. I hope you liked this approach to gather all the news related to a topic at one place.

The code can be found at Github.

Your comments are most welcome. Let me know what do you think of this idea.

+ Leave a Comment