Giter VIP home page Giter VIP logo

followercounthistory's Introduction

Twitter Follower Count History via Internet Archives

This is a Python script that collects follower counts from the Internet Archives, given a Twitter user name. This script grabs the follower counts by identifying various CSS Selectors that match the follower count element on the historical Twitter pages for almost every major overhaul their page layout has gone through. The program only collects one data point per month by default.

Output

A csv file noting the date of the archived Twitter page, the follower count for that date, and a link to the memento. A csv file noting the date of the archived Twitter page, the reason follower count was not collected, and a link to the memento. Optional: A line graph displaying the collected data.

The program will print to the console the date it is currently processing 'YYYYMMDDHHMMSS' and the action taken to show it's progress.

The program will assume any previously available csv file of the proper name contains the proper data that FollowerHist.py would generate and will refrain from asking the archive for that date again. Thus if the data is wrong, the program will not fix it.

Installation and Usage

Dependencies

  • Python 3
  • R* (to create graph)
  • bs4
  • urllib
  • archivenow* (push to archive)
  • datetime* (push to archive)

*optional

Usage

$ git clone https://github.com/oduwsdl/FollowerCountHistory.git
$ cd FollowerCountHistory
$ pip install -r requirements.txt
$ ./FollowerHist.py [-h] [-g] [-e] [-p | -P] <twitter-username-without-@>

This will create a new folder with the name: <twitter-username-without-@> and create three files in this folder.

  • A .csv file that contains the data collected with associated timestamps
  • A .csv file that contains data for mementos follower count was not extracted from
  • A .png file that contains a line chart of the data collected with X axis representing time The R script is called from within the Python script, with the [-g] flag so no additional action is required.

To just create the graph from a csv file

$ git clone https://github.com/oduwsdl/FollowerCountHistory.git
$ cd FollowerCountHistory
$ Rscript --vanilla follower_count_linechart.R <twitter-username-without-@>

Docker

We have published a docker image at oduwsdl/fch, which can be used to run this tool as following:

$ docker container run --rm -it -v </OUTPUT/DIR>:/app/<TWITTER_HANDLE> oduwsdl/fch [OPTIONS] <TWITTER_HANDLE>

Options

-h	Help
-g	Create graph.
-p	Push to Internet Archive. Will only push if last memento is not within current month. 
        Need additional dependencies datetime and archivenow.	
-P      Push to all archives available through archivenow. 
        Will only push if last memento in Internet Archive is not within current month. 
        Need additional dependencies datetime and archivenow.	
-e      Collect follower count from every memento, not just once per month.

followercounthistory's People

Contributors

okrand avatar miranda-c-smith avatar ibnesayeed avatar machawk1 avatar

Stargazers

Scott Anderson avatar

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.