Collection of twitter utilities.
Project description
Twitter tools
Documentation: https://namuan.github.io/twitter-utils
Source Code: https://github.com/namuan/twitter-utils
PyPI: https://pypi.org/project/twitter-utils/
Collection of twitter utilities.
Installation
pip install twitter-utils
Example Usage
All commands in twitter-utils
work better with an authenticated user otherwise Twitter bombards you with crap.
The following command is tested on MacOS and will create a symlink to your Firefox profile.
Please replace the source path with your own.
ln -s "~/Library/Application\ Support/Firefox/Profiles/.." $(pwd)/fireprofile
All commands take an argument to specify the output directory. Each tweet captured will be saved in the output directory to a file with the file name as the tweet id.
Grab tweets of an account between two dates
tweets-between --account <<account>> --since 2020-04-10 --until 2020-04-25 -o temp-dir
Grab tweets on a page
tweets-thread -a <<account>> -t <<tweet-id>> -o temp-dir
Using twarc to capture tweet data using Twitter API
You can use twarc to get tweets given a list of ids. Twarc uses Twitter API so you'll need those credentials. Twarc hydrate command that will grab tweet data given a list of ids.
# Depending on your output directory, here is a command to get the list of file name (tweet ids)
find <output-folder>/*.html | while read file; do basename $file ".html"; done > <target-file-with-list-of-tweet-ids>
# These feed this list of ids to twarc
twarc hydrate <target-file-with-list-of-tweet-ids> > <file-with-all-tweets-data>.jsonl
Selecting WebDriver
All commands in twitter-utils
uses Firefox by default, but it can be overridden by providing an alternate browser.
Supporting Firefox, Safari and Chrome.
To use Safari instead of Firefox, pass the --browser
option before specifying the sub-command.
<cmd> --browser safari ...
And to use Chrome
<cmd> --browser chrome ...
Development
- Clone this repository
- Requirements:
- Poetry
- Python 3.7+
- Create a virtual environment and install the dependencies
poetry install
- Activate the virtual environment
poetry shell
Validating build
make build
Release process
A release is automatically published when a new version is bumped using make bump
.
See .github/workflows/build.yml
for more details.
Once the release is published, .github/workflows/publish.yml
will automatically publish it to PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file twitter-utils-0.5.0.tar.gz
.
File metadata
- Download URL: twitter-utils-0.5.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 957802fb0b8ebb765456d54ad1cd5d9dc9995d2497006c513981440a7d8f262a |
|
MD5 | c5f43e38f0f0bc434a9cfb0f878b05dc |
|
BLAKE2b-256 | ecd60b2ec6ab9bc88c951b39d009873491778c3a18e6a71d4400005a7c07811b |
File details
Details for the file twitter_utils-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: twitter_utils-0.5.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87f496a4a90ec0991c89c66d46b4e854ea2d75bdfe172bd05ff67cdba9afd3d2 |
|
MD5 | dec6ebe63949c7507617eba7f72403ca |
|
BLAKE2b-256 | b05b13271f1b17f0e067bc891460b716844e2e7e6905df22beffe0a83eb96c13 |