是否需要一种 MIME 类型来确保与 RSS 阅读器和其他 Scraper 的兼容性?
选择似乎是:
有趣的是 Stackoverflow 使用 text/html。
都不是,是强度 application/rss+xml Http://www.rssboard.org/rss-mime-type-application.txt
application/rss+xml
可以使用 text/xml,但正确的 MIME 类型应该是 application/rss+xml。
text/xml
如果你想确保你的 feed 与 RSS 阅读器和其他 Scraper 兼容,那么使用 MIME application/rss + xml是安全的。我就用这个。
其他评论者指出,单一正确的哑剧类型是 application/rss+xml,。
application/rss+xml,
但是,如果您正在为客户端设置一个接受标头,那么
Accept: application/rss+xml, application/rdf+xml;q=0.8, application/atom+xml;q=0.6, application/xml;q=0.4, text/xml;q=0.4
可能是一个不错的选择,因为它声明接受 RSS、 Atom 和 XML (按降序或首选项)。
Text/xml 是唯一正确的答案。哑剧类型是一个基于注册的系统。有一个由 IANA (互联网号码分配局)管理的官方列表,位于 http://www.IANA.org/assignments/media-types/media-types.xhtml
这里有一个实用的答案: 无论“正确”的答案是什么(显然这方面存在争议) ,text/xml是非常流行的提要 所有所使用的类型。
这里有一些我检查过的:
$ for f in \ https://feeds.feedburner.com/TechCrunch/ \ http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml \ http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml \ https://daringfireball.net/thetalkshow/rss \ http://www.npr.org/rss/podcast.php?id=381444908 \ http://feeds.serialpodcast.org/serialpodcast \ http://podcasts.joerogan.net/feed \ https://feeds.feedburner.com/thetimferrissshow \ http://feed.thisamericanlife.org/talpodcast ; do \ curl -s -I $f | fgrep -i Content-Type: ; done content-type:text/xml; charset=UTF-8 Content-Type: text/xml Content-Type: text/xml Content-Type: text/xml;charset=UTF-8 Content-Type: text/xml;charset=UTF-8 Content-Type: text/xml; charset=UTF-8 Content-Type: text/xml; charset=UTF-8 content-type:text/xml; charset=UTF-8 Content-Type: text/xml; charset=UTF-8
因此,您可以确保通常使用的 RSS 客户端能够正确地解释 text/xml。
最大的 正确是 application/rss+xml
最大的 兼容是 application/xml
application/xml
W3C 表示:
RSS 提要应该作为 application/RSS + xml 提供(RSS 1.0是 RDF 格式,因此它可以作为 application/rdf + xml 使用) 提要应该使用 application/atom + xml 与广泛部署的网络浏览器兼容,任何这些提要 可以使用一种更通用的 XML 类型——最好是 Application/xml.
Https://validator.w3.org/feed/docs/warning/unexpectedcontenttype.html