Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jqueryajax获取googleresults源代码_Javascript_Jquery_Ajax_Cross Domain - Fatal编程技术网

Javascript 如何使用jqueryajax获取googleresults源代码

Javascript 如何使用jqueryajax获取googleresults源代码,javascript,jquery,ajax,cross-domain,Javascript,Jquery,Ajax,Cross Domain,我想在我的网站上获得一些谷歌搜索结果,我知道我可以通过curl、php获得,但是对于相同的ip地址,它每天的搜索量是有限的。我不想使用谷歌搜索api,因为它也有限制。所以我想我可以使用jQueryAjax,但我对这方面有点陌生,我受够了这个问题。 这是我的代码,由于jsonp格式的原因,它总是会出错,但也许还有一种方法可以捕获html源代码。我看到源代码出现在我的浏览器中,但我不能像对待对象一样对待它。我尝试了xhr.responseText等,但它也给出了语法错误,我仍然无法得到。 如果你可以

我想在我的网站上获得一些谷歌搜索结果,我知道我可以通过curl、php获得,但是对于相同的ip地址,它每天的搜索量是有限的。我不想使用谷歌搜索api,因为它也有限制。所以我想我可以使用jQueryAjax,但我对这方面有点陌生,我受够了这个问题。 这是我的代码,由于jsonp格式的原因,它总是会出错,但也许还有一种方法可以捕获html源代码。我看到源代码出现在我的浏览器中,但我不能像对待对象一样对待它。我尝试了xhr.responseText等,但它也给出了语法错误,我仍然无法得到。 如果你可以向我建议任何其他方式,或者如果你对下面的代码有任何想法,请与我分享。 谢谢你

$.ajax({
    url:"http://www.google.com.tr/search?q=ercan", 
    dataType: 'jsonp', 

    success:function(json){
         // I know its wont never succes, because google gives source in html format
         alert("Success");
    },
    error:function(xhr){
         //I want to get source code html here, but its giving always parse end syntax error I cant get it
         console.log(xhr);
    },
});

恐怕您只能选择使用API或服务器端桥接脚本。如果服务器不支持JSONP或CORS,则无法进行跨域AJAX调用。还有一个商业版的API,它允许您增加可以发送的请求的限制