Git Product home page Git Product logo

tweet-tracker's Introduction

Tweet Tracker

Track and store realtime tweets.

Requirements

This is a Python 3 project that requires pip or whatever python package manager you like. To install all modules and dependencies, enter your python virtual environment and run:

pip install -r requirements.txt

Since the software consumes Twitter official API to track tweets, you have to register for Twitter Developer to get your own API keys.

Settings

Some tracking settings are required to start:

  • Words to track in tweets text: words list separated by white spaces
  • Tweets languages to filter: language shorthands (en, pt, fr...) list separated by white spaces
  • Threshold: number of tweets to track

And Twitter API keys:

  • CONSUMER KEY
  • CONSUMER SECRET
  • ACCESS KEY
  • ACCESS TOKEN SECRET

If you intend to run this program multiple times using the same settings, consider creating a file containing settings values, each per line. Below is an example of settings file to track 10000 tweets in english containing words that refer to the COVID-19 pandemic:

covid-19 covid covid19 coronavirus pandemic
en
10000
CONSUMER_KEY
CONSUMER_SECRET
ACCESS_KEY
ACCESS_TOKEN_SECRET

Running

This is a CLI Python software, so the command below starts the program. You can pass a optional argument for the settings file or set its values at runtime in default input.

python app.py [settings_file]

All set, the program will first try to authenticate your Twitter credentials and it must accomplish this successfully to proceed. Then, the tracking process starts printing each tweet found until reach the threshold or after you manually canceling by pressing CTRL + C.

The process splits tweet info into 6 fields:

  • id: tweet original Twitter id
  • datetime: whenever the tweet was published
  • location: tweet's owner location
  • text: tweet content text
  • hashtags: hashtags into tweet
  • mentions: mentions into tweet

Retweets and text case differences are intentionally ignored.

A log file into log folder will be automatically created for each execution.

Result

All tracked tweets are stored in a CSV file named as tweets_{date}T{time}.csv inside data folder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.