Skip to content

jakubvalenta/archive-twitter-account

Repository files navigation

Archive Twitter Account

A script to archive a public Twitter account. It downloads all tweets as one JSON Lines file and all photos as JPEGs or PNGs.

It uses twarc under the hood.

Prerequisites

You will need to sign up for a Twitter developer account, create a Project and an App, and get your App's key and tokens.

Installation

  1. Install Python 3.

    On Mac:

    $ brew install python3

    On Arch Linux:

    # pacman -S python
  2. Install this project's dependencies:

    $ python -r requirements.txt

Usage

  1. Get your Twitter App's bearer token (it should be somewhere here) and export it as an environment variable:

    $  export BEARER_TOKEN='<your twitter app bearer token>'
  2. Call this project's script with the username of the Twitter account you'd like to archive. Example:

    $ ./archive-twitter-account TwitterDev
  3. Done. You can now find the downloaded data in the ./data directory. Example:

    data
    └── TwitterDev
        ├── media
        │   ├── Ffbx1jMXoAEU7Fh.jpg
        │   ├── ...
        │   └── FevXHTtXoAAoGyu.jpg
        ├── media_objects.jsonl
        └── timeline.jsonl
    

Contributing

Feel free to remix this project under the terms of the Apache License, Version 2.0.