gpt4 book ai didi

javascript - 雅虎查询语言 - RSS

转载 作者:行者123 更新时间:2023-11-28 07:37:25 25 4
gpt4 key购买 nike

var site = 'www.mysite.com/news.aspx?rss=1';
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + site + '"') + '&format=xml';
$.get(yql).done(function (rss)
{
//do the Things
}

目前我有此功能尝试加载外部站点 RSS 提要。不幸的是,它没有正确加载提要,所以我无法做这些事情。此提要使用 Google Feeds Api 正确加载,但由于该提要很快就会被弃用,我尝试转向在 Javascript 中使用不同的 RSS 加载方法(跨域)。我对 YQL url 的操作有误吗?

        error="Redirected to a robots.txt restricted URL: http(s)://www.mySite.com/news.aspx?rss=1"

最佳答案

使用以下 URL 映射作为测试:

'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="http://www.bls.gov/feed/empsit.rss"')

生成有效的 YQL 查询:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Fwww.bls.gov%2Ffeed%2Fempsit.rss%22

具有以下 JSON 替代输出:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Fwww.bls.gov%2Ffeed%2Fempsit.rss%22&format=json

并记住以下限制以进行故障排除:

YQL uses the robots.txt file on your server to determine the Web pages accessible from your site. YQL uses the user-agent "Yahoo Pipes 2.0" when accessing the robots.txt file and checks it for allows/disallows from this user agent. If the robots.txt check does prevent YQL from accessing your content, it will then fetch the target page using a different user agent:

因此,要允许 YQL 访问您的内容,只需将“Yahoo Pipes 2.0”添加到 robots.txt 的相关部分即可。例如:

User-agent: Yahoo Pipes 2.0
Allow: /

引用文献

关于javascript - 雅虎查询语言 - RSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28437932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com