How to serve up the most recent wordpress blog entry inside a TG page?

0 views
Skip to first unread message

Matt Wilson

unread,
Dec 9, 2006, 1:30:23 PM12/9/06
to TurboGears
I have a wordpress blog on my site. On a TG page, I'd like to somehow
display the first first paragraph from the blog.

When I look at the RSS feed for the blog, there's a description node
that has exactly the text I want.

I see two ways to do this, but I hope somebody else has a better idea.
1. Hit the MySQL database from TG and extract the stuff I want in my
controller. I don't really like this approach because it requires
going to another database.

2. Somehow grab the RSS feed off localhost, do some XML parsing to grab
the description section, and display that.

Like I said, I hope somebody has a better solution.

TIA

MAtt

Elvelind Grandin

unread,
Dec 9, 2006, 2:34:08 PM12/9/06
to turbo...@googlegroups.com

Doing it this way should be easy using feedparser http://feedparser.org/
d = feedparser.parse("http://...")
for item in d.feed:
print item.description

or something like that.

>
> Like I said, I hope somebody has a better solution.
>
> TIA
>
> MAtt
>
>
> >
>


--
cheers
elvelind grandin

Reply all
Reply to author
Forward
0 new messages