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.
Metadata
Release files for twitter-utils 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| twitter-utils-0.5.0.tar.gz | 8.3 kB | Without provenance | Details for twitter-utils-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| twitter_utils-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for twitter_utils-0.5.0-py3-none-any.whl |
Total release size: 17.3 kB
Release files / twitter-utils-0.5.0.tar.gz
| Download URL | twitter-utils-0.5.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
957802fb0b8ebb765456d54ad1cd5d9dc9995d2497006c513981440a7d8f262a
|
|
BLAKE2b-256 checksum How to use checksums |
ecd60b2ec6ab9bc88c951b39d009873491778c3a18e6a71d4400005a7c07811b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure
|
Release files / twitter_utils-0.5.0-py3-none-any.whl
| Download URL | twitter_utils-0.5.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87f496a4a90ec0991c89c66d46b4e854ea2d75bdfe172bd05ff67cdba9afd3d2
|
|
BLAKE2b-256 checksum How to use checksums |
b05b13271f1b17f0e067bc891460b716844e2e7e6905df22beffe0a83eb96c13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure
|
Security for twitter-utils 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.