Instructables

Getting instructable counts. (continued)

Picture of Getting instructable counts. (continued)
Screenshot-Select a iurl file to read.png
Screenshot-Text View.png
Screenshot-eddie@oesrvr104: ~.png
Screenshot-Untitled 1 - OpenOffice.org Calc.png
Notice: Becuase Instrucables has changed their web pages again, this instructable will not work. I am working on a fix.

In the last instructable we just displayed the data. Now we will modify the code and then use the code to get the data and the counts for importing into a spreadsheet . Sorry I did not use an icon. You can do that.

Original data:

idata: (not do not type in "[data]" or [/data] or you will get an error)
[data]
http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/
http://www.instructables.com/id/Gut-Check-Fridge-a-Tweeting-and-Facebooking-Fri/
http://www.instructables.com/id/Air-quality-balloons/
http://www.instructables.com/id/Sun-Bottles/
http://www.instructables.com/id/Wrap-around-workbench-under-100/
http://www.instructables.com/id/Solar-PV-tracker/
[/data}

We now have a modified program:

gidata2ss.sh:
[code]
#================================
#
# Instructablesnumbers catcher
#
#=================================
# Assignments
# --------------------------------
szAnswer=$(zenity --file-selection --title="Select a iurl file to read")
datafile=$szAnswer
outfile="inumdata"
# 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
# uncomment the following line if you want to see the url and or views
echo "$theurl"
# get total views
# elinks "$theurl" | grep "Total Views"
# get all the info
# elinks "$theurl" | grep Views
# just get numbers
elinks "$theurl" | grep -m 1 "Total Views" | cut -c 16-25 | sed 's,\,,,g' >> $outfile
done < $datafile
zenity --text-info --filename=$outfile
[/code]

Run program to get data.
Start new spreadsheet.
Copy and paste numbers into spreadsheet (use fixed with and special numbers)
Add column titles
Copy paste URL's (with fixed length.)
Save and done.


Included a short movie to show how it works.



Update:

Wrote a new version of the script and it should work better.

[code]
#================================
#
# Instructablesnumbers catcher
#
#=================================
# Assignments
# --------------------------------
szAnswer=$(zenity --file-selection --title="Select a iurl file to read")
datafile=$szAnswer
outfile="inumdata"
# 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
curl -s "$theurl" | grep -m 1 "hits-count" | sed 's/[^0-9]*//g' >> $outfile
done < $datafile
zenity --text-info --filename=$outfile
[/code]


-----------------------------------------------------------------------------

Partial temp fix

#================================
#
#  Instructablesnumbers catcher
#
#=================================
# Assignments
# --------------------------------
szAnswer=$(zenity --file-selection --title="Select a iurl file to read")
datafile=$szAnswer
outfile="inumdata"
total=0
# 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

--------------------------------------------------------------
Yet another temporary fix.
While looged in:
#================================
#
#  Instructablesnumbers catcher
#
#=================================
# Assignments
# --------------------------------
szAnswer=$(zenity --file-selection --title="Select a iurl file to read")
datafile=$szAnswer
outfile="inumdata"
total=0
# 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


=======================================================

Get favs by:
#================================
#
#  Instructablesnumbers catcher
#
#=================================
# Assignments
# --------------------------------
szAnswer=$(zenity --file-selection --title="Select a iurl file to read")
datafile=$szAnswer
outfile="inumdata"
total=0
# 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 "favorites" | sed 's/[^0-9]*//g')
# let total=$total+$count
echo "$count" >> $outfile
done < $datafile
# echo "total: $total" >> $outfile
zenity --text-info --filename=$outfile


 
Computothought (author) 2 years ago
Updated code in progress for the new format. Let me know if it does not work for you. If you have instructables html that are not updated, then it may miss a count.
[code]
outfile="inumdata"
# 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"
# get total views
curl -s "$theurl" | grep "hits-count" | sed 's/[^0-9]*//g' >> $outfile
done < $datafile
zenity --text-info --filename=$outfile
[/code]
Computothought (author)  Computothought2 years ago
At least the numbers are more accurate now than with the old web pages they used.
sunshiine2 years ago
Again thanks for sharing!
Sunshiine
Computothought (author)  sunshiine2 years ago
Thanx for the kind comment!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!