curl错误:警告:curl_exec():45不是有效的cURL句柄资源 [英] curl error : Warning: curl_exec(): 45 is not a valid cURL handle resource

查看:431
本文介绍了curl错误:警告:curl_exec():45不是有效的cURL句柄资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从Google搜索中获取数据。我使用下面的代码

I was trying to fetch data from google search. I used the below code

$curl = curl_init();   
curl_setopt ($curl, CURLOPT_URL, "http://www.google.com/search?output=toolbar&q=".urlencode($fkey));  
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);  
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);  
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);  
$contentstring = curl_exec ($curl);
curl_close ($curl);
print $contentstring; 



但是它没有显示如下的页面


But its not displaying the page like below



请有人帮我解决这个问题……预先感谢


Please somebody help me to solve this... Thanks in advance

推荐答案

您的代码运行正常。

如您所见,图像.. Google阻止了您IP地址中的请求,因为它检测到异常的流量活动。

As you can see the image.. Google have blocked the request from your IP address as it detected unusual traffic activity.

您始终可以检查您的请求URL给出的HTTP状态代码。

You can always check the HTTP Status Code what your requesting URL gives by..

echo $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

如果一切正常,您将得到 200 响应,否则您将获得一些其他状态代码。

If everything is normal , you would get a 200 response, else you will get some other status code.

以下是最常见的HTTP状态代码。

Here are the most common HTTP Status Codes..

这篇关于curl错误:警告:curl_exec():45不是有效的cURL句柄资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆