It is currently April 20th, 2024, 5:42 am

Using Google Reader to parse feeds. [No longer works]

Tips and Tricks from the Rainmeter Community
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Using Google Reader to parse feeds. [No longer works]

Post by poiru »

I'd like to share a method with which one skin (or RegExp) can handle virtually all feeds. The idea is to use Google Reader, which reads the feeds (be it Atom, RSS, or anything else it supports) and displays them using it's own format.

The address:

Code: Select all

http://www.google.co.uk/reader/view/feed/#URL#?n=8
#URL# can be any feed (e.g. http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml).
?n=8 tells Google Reader to show 8 items. You can change this to a lower/higher number depending on your need.

The code below will return the following:
- the title of the feed (e.g. BBC News)
- the link to 8 items (if they exist -- the RegExp won't fail if <8 items are available)
- the title to 8 items (if they exist)
- the date of 8 items (if they exist)

Code: Select all

[Variables]
URL=http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml
GET=.*(?(?=.*<div class="item">).*<div class="item">.*<a href="(.*)">(.*)</a>.*<div class="item-info">.* on (.*)</div>)

[MeasureFeed]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=http://www.google.co.uk/reader/view/feed/#URL#?n=8
RegExp="(?siU)<h1>(.*)</h1>#GET##GET##GET##GET##GET##GET##GET##GET#"
UpdateRate=1500
Enjoy ;)

(Oh, and I use google.co.uk to get the date in DD/MM/YY. With .com it'd be MM/DD/YY)
Last edited by poiru on December 18th, 2009, 4:17 pm, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by jsmorley »

This is an EXECELLENT "Tips and Tricks". Thanks. Clearly explained and with example code. Perfect. I will be adding it to the documentation on the main site.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by dragonmage »

Nice use of Variables for the RegExp legace! I hadn't thought of that before.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by poiru »

jsmorley wrote:This is an EXECELLENT "Tips and Tricks". Thanks. Clearly explained and with example code. Perfect. I will be adding it to the documentation on the main site.
Glad you like it.

By the way, you could consider adding this to "Converting Degrees to Radians for Angle and Rotate": http://www.google.com/search?q=40+degrees+in+radians
dragonmage wrote:Nice use of Variables for the RegExp legace! I hadn't thought of that before.
Yeah, it's much easier to understand the code that way.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by jsmorley »

legace wrote: Glad you like it.

By the way, you could consider adding this to "Converting Degrees to Radians for Angle and Rotate": http://www.google.com/search?q=40+degrees+in+radians
Yeah, it's much easier to understand the code that way.
http://rainmeter.net/cms/Tips-DegreesAndRadians
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by jsmorley »

User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by Kaelri »

I wish I'd thought of that #GET# method myself. Hats off. Nice work. :)
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by Chewtoy »

I'm a tad curious. Which part is it that make this able to run even tough there's missing feeds?
THAT would be great if it could be explained.
Is it the (?(?= that makes it or what?
I don't think, therefore I'm not.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by jsmorley »

Chewtoy wrote:I'm a tad curious. Which part is it that make this able to run even tough there's missing feeds?
THAT would be great if it could be explained.
Is it the (?(?= that makes it or what?
Yes.

http://www.regular-expressions.info/lookaround.html
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Using Google Reader to parse Atom, RSS, etc. feeds

Post by poiru »

Chewtoy wrote: Is it the (?(?= that makes it or what?
Yeah. Basically: If <div class="item"> exits, then <a href="(.*)">(.*)</a>.*<div class="item-info">.* on (.*)</div>.