Skip to content

A streaming engine for live fetching tweets into a MongoDB

License

Notifications You must be signed in to change notification settings

giuetr/tweetstream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tweetstream

A streaming engine for live fetching tweets and store them into a MongoDB database.


Tweetstream is a light and functional solution for parsing Tweets in real time and storing them in a local MongoDB collection.

An easy-to-use starting point to implement different analysis routines including sentiment analysis, textual analysis and other parsing methods.

I.e.: the app can collect and store tweets based on a group of tickers ('#ADBE', '#NVDA', '#ORCL', ...).

Requirements:

  • tweepy
  • pymongo
  • The Twitter Streaming API keys
  • MongoDB installed locally

Editing

The code can be used as-it-is, just edit it with your Twitter Streaming API keys:

consumer_key = "your consumer key"
consumer_secr = "your consumer secret"
access_tkn = "your access token"
access_tkn_secr = "your access token secret"

Point it to your local MongoDB:

host_mongo= 'mongodb://localhost:XXXXX/twitterdb'

And edit the 'tags' list with your hashtags of interest:

tags = ['#EU','#Italy','#Germany','#Libra',...]

Launch

Simply launch it via prompt and start collecting tweets in real-time:

$ python tweetstream.py

In the following example we are tracking Libra, Facebook's new cryptocurrency:

The stream is on and Tweets are stored in our database collection:

License:

GNU General Public License v3.0

Copyright © 2021 giuetr