YQL查询服务现在被雅虎关闭了

问题描述 投票:11回答:3

所以现在雅虎关闭了query.yahooapis.com,如下面的消息所示,有没有人知道免费更换?

“重要的EOL通知:截至2019年1月3日星期四,query.yahooapis.com上的YQL服务将被淘汰。这将影响datatables.org的用户以及使用此YQL服务创建功能的开发人员。继续使用我们的免费Yahoo Weather API,使用https://weather-ydn-yql.media.yahoo.com/forecastrss作为您的新API端点。请联系[email protected]获取此免费Yahoo Weather API服务的凭据。其他使用query.yahooapis.com的基于YQL的服务将不再运作。“

需要替换"//query.yahooapis.com/v1/public/yql?q="让我的rss scraper工作。

function yql(a, b) {
        return (
          "**//query.yahooapis.com/v1/public/yql?q=**" +
          encodeURIComponent(
            "select * from " +
              b +
              ' where url="' +
              a +
              '" limit ' +
              params.feedcount
          ) +
          "&format=json"
        );
      }
json rss yql
3个回答
3
投票

我找到了这个,对我来说很有用。 https://api.rss2json.com有一个自由层,它比YQL更直接用于RSS到JSONP的转换。


0
投票

我构建了CoudQuery,它能够将大多数网站转换为API,它有一个简单易用的Web界面来创建API。它在github上开源


-2
投票

这是一个可能的解决方案。

a)您需要某种代理来允许使用来自不同来源的ajax加载内容。建议将白名单并添加CORS标题等以防止利用您的代理。使用此功能在您的一台服务器上创建一个php文件:

$valid_url_regex = '/.*(rss|feed|atom).*/';
$url = $_GET['url'];
if ( !preg_match( $valid_url_regex, $url ) ) exit;

$feeds = file_get_contents($url);
//this is some workaround to get special namespaces into the json
$feeds = str_replace("<content:encoded>","<contentEncoded>",$feeds);
$feeds = str_replace("</content:encoded>","</contentEncoded>",$feeds);
$feeds = str_replace("<media:content ","<mediaContent ",$feeds);
$feeds = str_replace("</media:content>","</mediaContent>",$feeds);

$simpleXml = simplexml_load_string($feeds, "SimpleXMLElement", LIBXML_NOCDATA);//this is for CDATA
$json = json_encode($simpleXml);
header("Access-Control-Allow-Origin: http://yourdomainnamehere");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); 
print $json;

b)对proxy-script执行异步ajax调用并处理数据:

function loadRss(url)
{
    $.ajax({
        url: 'yourserverurl/rssproxy.php?url='+url,
        type: 'GET',          
        success: function(response) {
            handleResponse(JSON.parse(response));
        }
    });
}


function handleResponse(response) { 
    var entries; 

    if(response.entry) //ATOM
        entries = response.entry;
    else if(response.channel.item) //RSS 1/2
        entries = response.channel.item;

    var feedTitle="";

    if(response.title)
        feedTitle = response.title;
    else if(response.channel.title)
        feedTitle = response.channel.title;

    //iterate all news entries
    $.each(entries, function (i, e) {
            console.log("Entry #"+i);
            console.log(e);
            //access the data as necessary like e.content, e.summary, e.contentEncoded etc....
    }
    );

}

我几年前将我的google rss api更改为YQL,现在我今天必须再做一次,花了几个小时,但这次你不会依赖某些第三方供应商,希望你可以使用你的新读卡器代码直到对于着名的过滤泡沫,rss优先于人类消失;)

上面的代码只是一个提示,当然如果你想将响应映射到广义的YQL结构,你将不得不投入一些时间。我没有这样做,并根据需要访问响应的属性。

© www.soinside.com 2019 - 2024. All rights reserved.