Showing posts with label comments. Show all posts
Showing posts with label comments. Show all posts

Thursday, April 17, 2014

Script to check social shares: Facebook comments, shares and likes, tweets, G+ ripples, linkedin and stumbles


Social shares on Facebook, Linkedin, Twitter, Google Plus are relevant - for users, and we assume as well for rankings in search engines. (likely not directly, but indirectly through user behavior). There's a post checking a few platforms - now with more than ever! %-)

This is the version I use most - it covers the biggest relevant platforms (here in the US), and pulls it in the right speed. With my current internet connection, it just pulls slowly enough to not trigger any blocks from the api-s.

I also realized it is easiest to use a random file name, rather than pulling some info in from the site scanned. The url list can come from a sitemap scan or from a sitescan - or any other url list.

This is how the results look like:


I usually sort by each column, to filter out 'outliers', and then use the results.

This is the script:

#!bash
# set all variables to zero at the beginnning! then value >, replace
# check where the tabs come from (likely one tab to many in one of the echos?
rm "${1}-all-social-shares".csv

echo -e "Url\tripples\tFB-comments\tFB-shares\tFB-likes\ttwitter\tstumble_upon\tlinkedin" > "${1}-all-social-shares".csv
while read -r shortline ;

 do
line=$(echo $shortline | sed -e 's/\?/\%3F/g' -e 's/&/\%26/g' -e 's/#/\%23/g')
echo $shortline
echo $line
 number=0
 re='[0-9]+'
gpull="https://plus.google.com/ripple/details?url=${line}"
ripples=$(wget -qO- "${gpull}" | grep -o "[0-9]*\s*public\s*shares.<" | sed "s/[^0-9]//g"  | tr "\n" "\t" | sed 's/\thttp/\nhttp/g'| sed 's/\t//')

commentpull="https://api.facebook.com/method/fql.query?query=select%20comment_count%20from%20link_stat%20where%20url=%22${line}%22&format=json"
comment_count=`wget -qO- $commentpull | sed -e 's/^.*://g' -e 's/\}//g' -e 's/\(]\)//g'`

sharepull="https://api.facebook.com/method/fql.query?query=select%20share_count%20from%20link_stat%20where%20url=%22${line}%22&format=json"
share_count=`wget -qO- $sharepull | sed -e 's/^.*://g' -e 's/\}//g' -e 's/\(]\)//g'`

likepull="https://api.facebook.com/method/fql.query?query=select%20like_count%20from%20link_stat%20where%20url=%22${line}%22&format=json"
like_count=`wget -qO- $likepull | sed -e 's/^.*://g' -e 's/\}//g' -e 's/\(]\)//g'`

twitterpull="http://urls.api.twitter.com/1/urls/count.json?url=${line}&callback=twttr.receiveCount"
twitternumber=$(wget -qO- "${twitterpull}"  | grep -o 'count\":[0-9]*\,' | sed -e 's/count//g' -e 's/,//g' -e 's/://g' -e 's/"//g' )

stumblepull="http://www.stumbleupon.com/services/1.01/badge.getinfo?url=${line}"
stumblenumber=$(wget -qO- "${stumblepull}" | grep -o 'views\":[0-9]*\,' | sed -e 's/views//g' -e 's/,//g' -e 's/://g' -e 's/"//g' )

linkedpull="http://www.linkedin.com/countserv/count/share?format=json&url=${line}" #echo ${linkedpull}
linkednumber=$(wget -qO- "${linkedpull}" | grep -o 'count\":[0-9]*\,' | sed -e 's/count//g' -e 's/,//g' -e 's/://g' -e 's/"//g' )

#echo -e "$line\t$value\t$comment_count\t$share_count\t$like_count" >> "$1-all-public-shares".txt
echo -e "${line}\t${ripples}\t${comment_count}\t${share_count}\t${like_count}\t${twitternumber}\t${stumblenumber}\t${linkednumber}" >> "${1}-all-social-shares".csv


done < $1



Thursday, March 6, 2014

Moz Guest blogging - not just great for shares on Google Plus, but also on Facebook


As shown in earlier post - guest blogging on moz.com works really well. And it works well for the guest bloggers as well as for moz - getting all the link love, attention, traffic.

In the earlier posts I show the public Google Plus shares for the User generated content blog - and also for the company generated blog. This time I checked for Facebook comments, shares and likes, with the small script here to pull the data fresh from the public Facebook api.

This is the number of Facebook comments, facebook shares and facebook likes for the guest blog posts on moz (based on the sitemap for user generated content).


This hints at two things:

  1. SEO's really are into Google plus (no big surprise)
  2. The moz strategy works even for other social media, which in turn might be a good signal for google: not showing just on one social site, but on several.

Thursday, February 27, 2014

Script to get Facebook Comments, FB Shares and facebook likes for a list of urls

Another little helper script - this time tapping into the facebook api to get comments, shares and likes.
The access to this api does not require a login or account, but cuts off after ~ 400 requests. This is much more than I usually need, so no modification of this script to get over the limit. (One could think of a timer with 'sleep 600' after 400 loops or so).

#!bash
first add a header into the output file - dynamic pagename based on input file $1 (first parameter to call with the file), then start the loop for each url. Each loop includes 3 wget calls to the FB api for different values.
echo -e "FB-comments\tFB-shares\tFB-likes\tUrls" > "${1}"-store.csv
 while read -r line; do
#line="${1}"
generate the url
pull="https://api.facebook.com/method/fql.query?query=select%20comment_count%20from%20link_stat%20where%20url=%27${line}%27&format=json"
pull the data with wget, remove unnecessary parts with sed, and store in the variable comment count
comment_count=`wget -qO- $pull | sed -e 's/^.*://g' -e 's/\}//g' -e 's/\(]\)//g'`
 now the same with shares and likes
pull="https://api.facebook.com/method/fql.query?query=select%20share_count%20from%20link_stat%20where%20url=%27${line}%27&format=json"
share_count=`wget -qO- $pull | sed -e 's/^.*://g' -e 's/\}//g' -e 's/\(]\)//g'`
#echo $share_count
pull="https://api.facebook.com/method/fql.query?query=select%20like_count%20from%20link_stat%20where%20url=%27${line}%27&format=json"
like_count=`wget -qO- $pull | sed -e 's/^.*://g' -e 's/\}//g' -e 's/\(]\)//g'`
#echo $like_count
add all three variables into the file where the data is stored
echo -e "${comment_count}\t${share_count}\t${like_count}\t${line}" >> "${1}"-store.csv
done < ${1}
I choose to store the data in variables and then to concatenate to one line with echo, because it makes it really easy to just separate this with tabs - echoing each item separately into the file would have required to remove the line break (\n) each time. 
Bookmark and Share