Wednesday, October 16, 2013

Check URLs for ripples

How many ripples does a page have? Thanks to +AJ Kohn we have a little browser snippet showing this for each individual page.

How about a list of pages?


See number of ripples for all urls in a textfile

You can call this script in bash, adjust input file (urls.txt) and output file and location:
#!bash
while read -r line ;

do
number=0
re='[0-9]+'
pull="https://plus.google.com/ripple/details?url=${line}"
number=$(wget -qO- "${pull}" | grep -o "[0-9]*\s*public\s*shares.<" | sed "s/[^0-9]//g"  | tr "\n" "\t" | sed 's/\thttp/\nhttp/g')
if [[ $number =~ $re ]]; then
value=${number}
else
value="0"
fi
echo -e "$line\t$value" >> ~/Desktop/spider-public-shares.txt
done < urls.txt


Looping through urls.txt. Then wget a page, isolate the number of ripples, store it in a variable. If the value is a number not equal ( != ) zero, use it, if not, store zero in second variable $number. Then echo url ($line), tab, number value per url in the csv. This works only for ripples of regular pages, not for Google plus posts.

No comments:

Post a Comment

Bookmark and Share