【问题标题】:Detect if site has an RSS/Atom feed?检测网站是否有 RSS/Atom 提要?
【发布时间】:2012-07-22 09:38:49
【问题描述】:

我有一个网站的 URL,但没有它的提要,我想解析它。

如何 检测网站是否有 RSS/Atom 提要?

【问题讨论】:

    标签: ios nsurl


    【解决方案1】:

    在网站默认页面的 head 部分中查找 rel="alternate" type="application/rss+xml" 链接:

    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
      <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://someurl/feed/" />
      <title>Some title</title>
    </head>
    

    【讨论】:

    • 你能告诉我如何下载默认页面吗?总是 index.htm 吗?
    • 这将是当您尝试通过端口 80 下载页面 http://stackoverflow.com/ 时获得的页面。它可能有任何名称,因为它是通常在 Web 服务器中进行配置。
    • 另外,对于 ATOM 检查 type="application/atom+xml"
    【解决方案2】:

    正如这个问题中提到的How to check if a site has rss feeds 您需要下载该页面并检查 rel='alternate'。

    如果您想确保找到任何可能的 RSS/Atom 链接,如果第一次解析失败,您也可以对页面进行正则表达式以获取任何提及 feed.xml 或类似内容的回退。这不一定包含实际页面的 RSS,它可能是指向外部 RSS 的链接。

    【讨论】:

      猜你喜欢
      • 2011-07-23
      • 2011-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多