Skip to content

Instantly share code, notes, and snippets.

@elgreg
Last active April 19, 2019 13:48
Show Gist options
  • Save elgreg/a2777ca44a838c4c27a0340743ea8547 to your computer and use it in GitHub Desktop.
Save elgreg/a2777ca44a838c4c27a0340743ea8547 to your computer and use it in GitHub Desktop.
Get all the tweets in a thread starting at the end
#!/usr/bin/env bash
START=$1
CURRENT="${START}"
mkdir $START
download_tweet () {
twurl "/1.1/statuses/show/${CURRENT}.json" > "${START}/${1}.json"
}
download_all_tweets () {
echo $CURRENT
CURRENT="$1"
twurl "/1.1/statuses/show/${CURRENT}.json" > "${START}/${1}.json"
PREV=`cat ${START}/${CURRENT}.json | jq -r .in_reply_to_status_id_str`
if [ ! -z "$PREV" ]
then
echo "Going to get $PREV"
download_all_tweets $PREV
else
echo "Tweet not in reply"
fi
}
download_all_tweets $CURRENT
@elgreg
Copy link
Author

elgreg commented Apr 19, 2019

Usage ./get_all_tweets.sh 1119100319584022528 where 1119100319584022528 is the last tweet in a thread.

Requires twurl and the END of a well formed twitter thread (i.e. the last tweet is a reply to the second to last tweet which is a reply to the third to last tweet.

Will create a folder named after the tweet you pass in and then a separate file for each tweet.

Use your favorite bash stuff to do things with these files later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment