Skip to content

Instantly share code, notes, and snippets.

@sordina
Last active February 4, 2016 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sordina/0159bafd3e5fbc0c2f0c to your computer and use it in GitHub Desktop.
Save sordina/0159bafd3e5fbc0c2f0c to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# source $HOME/.google/api_keys
USER="$1"
if [ ! "$USER" ]
then
echo "Usage: google-plus-scrape-user USER_ID" 1>&2
exit 1
fi
if [ ! "$GOOGLE_PLUS_KEY" ]
then
echo "Error: Environment variable GOOGLE_PLUS_KEY must be set."
exit 1
fi
PREFIX="/tmp/google_plus_scraper/${USER}_$$"
BASE_URI="https://www.googleapis.com/plus/v1"
mkdir -p "$PREFIX"
echo "google-plus-scrape-user results being downloaded to $PREFIX" 1>&2
i=0
while True
do
((i+=1))
FILE="$PREFIX/$i"
curl -X GET "$BASE_URI/people/+$USER/activities/public?key=$GOOGLE_PLUS_KEY&maxResults=99&pageToken=$NEXT_PAGE_ID" > "$FILE"
cat "$FILE"
NEXT_PAGE_ID="$(jq -r '.nextPageToken // ""' < $FILE)"
if [ ! "$NEXT_PAGE_ID" ]
then
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment