html如何转换为opml,opml2html.pl -- a simple blogroller

作者分享了一个简单的Perl脚本opml2html.pl,该脚本可以从OPML文件中提取RSS订阅列表,并将其转换为XHTML代码,便于在博客侧边栏显示。通过定时任务自动运行此脚本,可以轻松保持博客订阅列表的实时更新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Several months ago I needed a way to keep my "blogroll" (list of RSS feeds I read, as seen on the side of my blog index page) up to date. Luckily, my news aggregator kept all the information in an OPML file called myChannels.opml. All I needed to do was extract the relveant information, sort it, spit out some HTML that can be included via SSI or PHP, and set it up to run from cron so that I don't have to think about it.

So I spent a few minutes on the problem and hacked out opml2html.pl. It's simple but does the job for me. Simply feed it an OPML file on STDIN and it'll spit back the XHTML code on STDOUT. That means you can run it like this: opml2html.pl < foo.opml > bar.html

A while back someone asked me how it I did this, so I sent the script. A few days ago, fellow Yahoo Michael Radwin asked how I did it. I sent him the script too. It turns out that his aggregator also produces a useful OPML file. He sent back patch today that improved it. That was enough to convince me that it's probably useful enough to share.

If someone is willing to patch your code, odds are good that several others are willing to use it.

Posted by jzawodn at December 26, 2002 02:51 PM

Reader Comments

# Jay Han said:

Jeremy: I did something similar with XSLT for my subscription OPML on Radio.

I admit your perl is tighter than my XSLT...

on December 26, 2002 03:31 PM

# Morten Frederiksen said:

Another XSLT solution to this, with integrated subscription links, is at http://purl.org/net/syndication/subscribe/.

See for example Jay Han's list at this address.

on December 26, 2002 05:05 PM

# l.m.orchard said:

I've been meaning to do this for ages and ages, but never quite crossed the laziness threshold :) I just set this up with my iBook, to rsync an HTML rendering of my AmphetaDesk subscriptions every few hours. I think it needs quite a bit of tweaking before it doesn't look like complete crap :)

on December 26, 2002 08:20 PM

# Geodog said:

Cool. I'll give it a whirl too, if you don't mind.

on December 26, 2002 09:05 PM

# l.m.orchard said:

(oh, in case I didn't make much sense: what looks like crap is my site, not the script :) )

on December 27, 2002 03:43 AM

# steven hatch said:

Here's a bit of Python code by Phillip Pearson that'll do the blogrolling trick as well.

on March 1, 2003 01:42 PM

# Gavin said:

I was inspired by your efforts to do a blogroll in OPML, but I ended up writing a Template Toolkit plugin for MT to do it :)

on March 16, 2003 04:12 PM

Disclaimer: The opinions expressed here are mine and

mine alone. My current, past, or previous employers are not responsible for what I

write here, the comments left by others, or the photos I may share. If

you have questions, please contact

me. Also, I am not a journalist or reporter. Don't "pitch" me.

Privacy: I do not share or publish the email addresses

or IP addresses of anyone posting a comment here without consent.

However, I do reserve the right to remove comments that are spammy,

off-topic, or otherwise unsuitable based on my comment

policy. In a few cases, I may leave spammy comments but remove any

URLs they contain.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值