Python script to grab (titles, links) from wordpress feeds.


Sometime last to last year I picked up Python. I studied it for a day, and feeling overwhelmed by my love for Perl, I ditched it the next day. I won’t tell you why (yeah, it’s a secret, unless someone comes along merrily who knows the secret and comments about it), but I picked up Dive Into Python, admittedly a great book to learn Python, last week. I’ve been reading it like anything ever since. And, although still nothing more than self-proclaiming, I can safely claim I know a lot of Python (I swear, for a moment there, I was typing Perl) now. And that is a good thing.

Enough of beating around the bush. I wrote a small python script, using xml.dom.minidom, to grab titles and links of posts from wordpress blog feeds. The script is available here. It can be used either as a standalone script or imported as a module from, say, the Python interactive shell. A brief example demonstrating its use:

>>> import gettitlesfromwordpress
>>> a = gettitlesfromwordpress.get_title_link(‘https://ayaz.wordpress.com/feed/’)
KDevelop
<https://ayaz.wordpress.com/2006/12/30/kdevelop/&gt;
….

The “get_title_link()” module can take anything for a URL, a wordpress feed file on hard-disk, to a wordpress feed as a string.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s