使用 shell 脚本读取 RSS feed
编辑:已翻译
我有一个 RSS 源想要解析。这是一个播客,我只想要 MP3-url 来使用 wget 下载它们。
这是播客:http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast
标题应包含 (de)
以仅获取德语剧集。 发布日期应该是今天。
如果有人能帮助我,那就太好了——我已经走到这一步了:
wget -q -O- view-source:http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast?format=xml| awk 'BEGIN{RS=""} /(date +'%d %M %Y')/{ gsub(/.*|.*/,"") print }
但它不起作用。
提前致谢, 阿内布3rt
Edit: Translated
I have a RSS-feed that i want to parse. It's a podcast and I want just the MP3-urls to download them with wget.
This is the podcast: http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast
The title should include an (de)
to get just the german episodes.
The publish-date should be today.
Would be great if someone could help me – I came this far:
wget -q -O- view-source:http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast?format=xml| awk 'BEGIN{RS=""} /(date +'%d %M %Y')/{ gsub(/.*|.*/,"") print }
But it doesn't work.
Thanks in advance,
arneb3rt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从 wget 命令中删除“view-source:”,并在 awk 命令之外执行 date 命令(使用 %b 来打印缩写月份而不是 %M)。以下 bash 脚本使用 grep 而不是 awk 来生成 wget 可以获取播客的 URL。
请注意,可能是由于假期的原因,自 2011 年 12 月 24 日起,Feed 中就没有播客了,因此我对最后一个播客的日期进行了硬编码以进行测试:
上述 bash 脚本的输出列出了两个 URL(一个是 feedburner,另一个是 feedburner)。另一个 iTunes):
因此,您可以从上述任一 URL 获取 2011 年 12 月 24 日的播客。
You need to drop the "view-source:" from the wget command and execute the date command (with %b to print the abbreviated month instead of %M) outside of the awk command. The following bash script uses grep instead of awk to produce the URLs of where wget can fetch the podcasts.
Note that, probably due to the holidays, there have been no podcasts since 24 Dec 2011 at the feed, so I hard-coded the date of the last podcast for testing:
The output of the above bash script lists two URLs (one feedburner and the other iTunes):
Therefore, you could wget the 24 Dec 2011 podcast from either of the above URLs.