Last active
July 4, 2024 18:13
-
-
Save cmj/ea72e7e136cdb1adf00c9bcd39016b2a to your computer and use it in GitHub Desktop.
Grab Twitter user stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# grab the stats from a twitter user | |
# requires account, 2 parameters from header | |
# output: | |
# 20240704-110910 tweets: 46561 friends: 650 followers: 188667122 likes: 58781 | |
x_csrf_token='' | |
auth_token='' | |
#### | |
user="elonmusk" | |
bearer_token='AAAAAAAAAAAAAAAAAAAAAFQODgEAAAAAVHTp76lzh3rFzcHbmHVvQxYYpTw%3DckAlMINMjmCwxUcaXbAN4XqJVdgMJaHqNOFgPMK0zN1qLqLQCF' | |
date=$(date +%Y%m%d-%H%M%S) | |
stats=$(curl -s "https://api.twitter.com/1.1/users/lookup.json?screen_name=${user//@/}" \ | |
-H "Authorization: Bearer ${bearer_token}" \ | |
-H "X-Csrf-Token: ${x_csrf_token}" \ | |
-H "Cookie: ct0=${x_csrf_token}; auth_token=${auth_token}" | \ | |
jq -r '.[] | "tweets: \(.statuses_count) friends: \(.friends_count) followers: \(.followers_count) likes: \(.favourites_count)"') | |
echo "${date} ${stats}" | |
#echo "${date} ${stats}" >> $file | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment