Tuesday, July 29, 2014

Instructables stat grab.

Many people have created tutorials on www.instructables.com. To see how each instructable is doing can be a chore. Devised a bash script to help conquer that chore. Though data may not be the latest, it certainly shows viable trends. You can also import the data into a spreadsheet rather easily.

First you will want to create a text file with the instructables you want to follow.
One url to a line.


You may need to install a program or two such as elinks and zenity so things will work. Then you will want to create an executable of the file to collect the data.

#  Instructables numbers catcher
# Assignments
# --------------------------------
szAnswer=$(zenity --file-selection --title="Select a iurl file to read")
# the date
tmon=$(date +"%b")
tday=$(date +"%d")
echo  "The views for $dj on $tmon $tday:" > $outfile
# Data input
while read line
do theurl=$line
echo  "$theurl"
# echo -n "$theurl'" >> $outfile
# get total views
# count=$(elinks  "$theurl" | grep -m 1 "hits-count" | sed 's/[^0-9]*//g')
count=$(elinks  "$theurl" | grep -m 1 "views" | sed 's/[^0-9]*//g')
# let total=$total+$count
echo "$count" >> $outfile
done < $datafile
# echo "total: $total" >> $outfile
zenity --text-info --filename=$outfile

Then it is a matter of running the script.

Just copy and paste the data into the spreadsheet.

You can also get instructable totals also.

# Today's numbers
# output data
# character width required for information box
# create data file (datadir and file name can be changed to your needs.
echo -n "Today's date: " >> $filename
date +%D >> $filename
echo "Today's numbers:" >> $filename
# echo -n "Total views  of www.instructables.com/member/$1/: "
echo computothought: >> $filename
# elinks  http://www.instructables.com/member/computothought | grep  '"Total Views" />'  | sed 's/[^0-9]*//g' >> $filename
elinks  http://www.instructables.com/member/computothought | grep  "Total Views"   >> $filename
echo davijordan: >> $filename
# elinks  http://www.instructables.com/member/davijordan | grep '"Total Views" />' | sed 's/[^0-9]*//g' >> $filename
elinks  http://www.instructables.com/member/davijordan | grep "Total Views"  >> $filename
# output
zenity --text-info --filename=$filename
# remove  unneeded file
 cp $filename $filename.old
 rm $filename

No comments:

Post a Comment