have a handy bash script that lets me download my gmail Inbox for processing - I'm looking for any similar script/command that lets me count (by some means) the total number of unread ideas in my google reader feed. Any Ideas?

Joe

link|improve this question

can you post a sample of the data? – John T Nov 9 '09 at 20:48
feedback

3 Answers

up vote 1 down vote accepted

You can use the following script substituting 'user' and 'pwd' with your google account credentials:

#!/bin/sh
SID=$(wget --output-document=- --post-data 'Email=user&Passwd=pwd' -q https://www.google.com/accounts/ClientLogin | grep -w SID);
unreadcountxml=$(wget --no-cookies --header "Cookie: $SID" --output-document=- -q http://www.google.com/reader/api/0/unread-count)
unreadcount=$(echo $unreadcountxml | awk 'BEGIN {RS="<object>";FS="count\">";sum=0} ; /reading-list/ {print $2}' | cut -d'<' -f1);
echo "Unread count: $unreadcount"

where you first obtain the Session ID, then obtain the atom feed of your subscriptions' unread items, and then extract the number of items in the fake subscription 'reading-list' that contains all the unread items.

link|improve this answer
feedback

I'd get the RSS feed, then parse that.

Getting http://www.google.com/reader/atom/user/{USERID}/state/com.google/reading-list

gives you your unread items as an atom feed. Counting the number of <title type="html"> for instance should give you the number of items - you could use grep for that.

link|improve this answer
By the way, you'd need to log in, using curl will let you login by posting the user+pass to the right place, then saving the cookies to a file. – Rich Bradshaw Nov 9 '09 at 21:59
feedback

You could try the ruby 'mechanize' library. Tons of mechanize examples with screen scraping and then performing some subsequent action on the response.

link|improve this answer
Mechanize also exists for Python, if that's your thing. – Phoshi Nov 11 '09 at 16:10
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.