首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yahoo YQL RSS -错误请求

Yahoo YQL RSS -错误请求
EN

Stack Overflow用户
提问于 2017-08-25 11:27:49
回答 3查看 610关注 0票数 3

为了使用jQuery发出跨域AJAX请求,我尝试使用YQL RSS。

代码语言:javascript
复制
select * from rss where url='https://www.top1000funds.com/feed/most-popular-posts/'

我的代码:

代码语言:javascript
复制
var feed = "https://www.top1000funds.com/feed/most-popular-posts/";
var yql = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22"+encodeURIComponent(feed)+"%22&format=json&diagnostics=true&callback=&rnd=_"+event.timeStamp;
console.log(yql);

$.getJSON(yql, function(res) {
    var html = '<div class="feedListWrap">';
    if(res.query && res.query.results && res.query.results.item){
        //code goes here
    } else {
        html += '<div class="feedEmpty">The feed is currently not available due to server issues. Check back soon!</div>';
    }
    html += '</div>';
    rssWrap.append(html);
}, "jsonp");

它工作得很好,但现在我在没有错误文本描述的json响应上得到了Bad Request问题:

代码语言:javascript
复制
{"query":{"count":0,"created":"2017-08-25T03:09:09Z","lang":"en","diagnostics":{"publiclyCallable":"true","url":{"execution-start-time":"0","execution-stop-time":"2","execution-time":"2","http-status-code":"400","http-status-message":"Bad Request","content":"https://www.top1000funds.com/feed/most-popular-posts/"},"user-time":"2","service-time":"2","build-version":"2.0.164"},"results":null}}

可以使用以下url查询进行测试:link

当尝试在YQL控制台中签入时,它工作正常:

代码语言:javascript
复制
{
 "query": {
  "count": 10,
  "created": "2017-08-25T02:54:38Z",
  "lang": "en-US",
  "diagnostics": {
   "publiclyCallable": "true",
   "url": {
    "execution-start-time": "1",
    "execution-stop-time": "8",
    "execution-time": "7",
    "content": "https://www.top1000funds.com/feed/most-popular-posts/"
   },
   "user-time": "8",
   "service-time": "7",
   "build-version": "2.0.164"
  },
  "results": {
   "item": [
    {
     "title": "OTPP’s private equity revolution",
     "link": "https://www.top1000funds.com/profile/2017/08/03/otpps-private-equity-revolution/",
     "pubDate": "Thu, 03 Aug 2017 06:39:33 +0000",
     "creator": "Sarah Rundell",
     "guid": {
      "isPermaLink": "false",
      "content": "http://www.top1000funds.com/?p=17673"
     },
     "description": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A deep dive into the world-class private capital division of OTPP, led by Jane Rowe, reveals a strategy of buying large direct stakes in companies, and a commitment to innovation.</div>",
     "encoded": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A deep dive into the world-class private capital division of OTPP, led by Jane Rowe, reveals a strategy of buying large direct stakes in companies, and a commitment to innovation.</div>"
    },
    {
     "title": "The value of the Canadian model",
     "link": "https://www.top1000funds.com/analysis/2017/08/08/the-value-of-the-canadian-model/",
     "pubDate": "Tue, 08 Aug 2017 04:53:00 +0000",
     "creator": "AMANDA WHITE",
     "guid": {
      "isPermaLink": "false",
      "content": "http://www.top1000funds.com/?p=17681"
     },
     "description": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A lot has been written about the superiority of the “Canadian model” for managing pensions, but can a value be assigned to this organisational design structure? </div>",
     "encoded": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A lot has been written about the superiority of the “Canadian model” for managing pensions, but can a value be assigned to this organisational design structure? </div>"
    },
    ...
   ]
  }
 }
}

有什么建议吗?

EN

回答 3

Stack Overflow用户

发布于 2017-08-26 01:28:03

我认为这是雅虎YQL端的一个问题,与使用的代码或其他东西无关。如果刷新查询,则会随机加载错误或正常。

我认为我们(用户)对此无能为力。雅虎需要解决这个问题。

票数 1
EN

Stack Overflow用户

发布于 2017-08-27 22:29:37

当在YQL控制台上试用时,我相信它会缓存结果。如果你进入调试模式,它将不会使用cahed的结果,因此你会更好地看到任何问题。

票数 0
EN

Stack Overflow用户

发布于 2017-09-07 20:11:25

在我看来,两天以来一切都运行得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45873994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档