Last active
February 4, 2016 03:18
-
-
Save sordina/0159bafd3e5fbc0c2f0c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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