如何从网站获取提要URL? [英] How to get the feed URL(s) from a website?
问题描述
按照官方文档礼貌地询问时,设置网站应指出其RSS/Atom提要的URL:
As per the official documentation, properly setup websites should indicate the URL of their RSS / Atom feed(s) when asked politely:
GET / HTTP/1.1
Host: example.com
Accept: application/rss+xml, application/xhtml+xml, text/html
当HTTP服务器(或服务器端脚本)获得此消息时,它应该将HTTP客户端重定向到提要.它应该使用HTTP来执行此操作302找到.像这样:
When an HTTP server (or server-side script) gets this, it should redirect the HTTP client to the feed. It should do this with an HTTP 302 Found. Something like:
HTTP/1.1 302 Found
Location: http://example.com/feed
我正试图得到这个答复,但是没有运气:
I'm trying to get this response, without luck:
request(
{ method: 'GET',
url: 'https://stackoverflow.com',
followRedirect :false,
accept: ['application/rss+xml', 'application/xhtml+xml', 'text/html']
}, function (error, response, body) {
console.log('statusCode: ', response.statusCode);
}
);
收益
statusCode: 200
如何制定我的请求,以便网站以供稿URL进行响应?
How do I formulate my request so that the website responds with the feed URL(s)?
推荐答案
网站将HTTP请求的RSS提要发送回首页以请求 application/rss + xml 接受标头中的MIME类型.您链接到的有关Mozilla的文档是我作为开发人员多年参与RSS之后从未见过的建议.
It is not common practice for websites to send back their RSS feed from an HTTP request to the home page asking for an application/rss+xml MIME type in the Accept header. That documentation on Mozilla you've linked is a suggestion I've never seen before after many years involvement in RSS as a developer.
一种用于站点识别RSS提要的更成熟且被广泛采用的方法是称为 RSS自动发现的技术..打开网站的主页,然后在 HEAD 部分中查找该标签:
A more established and widely adopted method for a site to identify its RSS feed is a technique called RSS Autodiscovery. Open the site's home page and look for this tag in the HEAD section:
<link rel="alternate" type="application/rss+xml" title="RSS"
href="http://feeds.example.com/rss-feed">
类型属性可以是RSS,Atom或JSONFeed提要的任何MIME类型.
The type attribute can be any of the MIME types for RSS, Atom or JSONFeed feeds.
这篇关于如何从网站获取提要URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!