Javascript yql会弄乱检索到的内容

Javascript yql会弄乱检索到的内容,javascript,jquery,cross-domain,jsonp,yql,Javascript,Jquery,Cross Domain,Jsonp,Yql,我正在尝试获取我的要点的原始内容,以便能够显示出来 代码如下: function requestCrossDomain(url, cb) { yql = "http://query.yahooapis.com/v1/public/yql?" + "q=" + encodeURIComponent('select * from html where url="' + url + '" ') + "&callback=?"; $.g

我正在尝试获取我的要点的原始内容,以便能够显示出来

代码如下:

function requestCrossDomain(url, cb) {

    yql = "http://query.yahooapis.com/v1/public/yql?" +
          "q=" + encodeURIComponent('select * from html where url="' + url + '" ') +
          "&callback=?";

    $.getJSON(yql, function (data) {
        if(data.results[0]){
            console.log(data.results[0]);
        }
    });
}

requestCrossDomain("https://gist.githubusercontent.com/gongzhitaao/11357604/raw/7946d46c975337084b18ff1d59530acc59c9e010/index.html");
data.results[0]
确实包含一些内容,但它是垃圾。
之间的代码由
分隔(在
渲染
功能中)???为什么?我错在哪里


这里是一个,正如您所看到的,这里只显示了
之间的部分代码。

最后我解决了这个问题。它似乎是参数
compat=“html5”
。默认的html规范是html4。我还需要
xpath
参数来选择
内容以及
内容。希望以下代码能对其他人有所帮助:

function requestCrossDomain(url, cb) {

    yql = "http://query.yahooapis.com/v1/public/yql?" +
        "q=" +
        encodeURIComponent('select * from html where url="' + url + '" ') +
        encodeURIComponent('and compat="html5" and xpath="//html/head|//html/body"') +
        "&format=xml&callback=?";

    $.getJSON(yql, function (data) {
        if(data.results)
            cb(data.results);
    });
}