1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php中抓取https页面 php抓取https url网页内容方法

php中抓取https页面 php抓取https url网页内容方法

时间:2018-12-05 09:13:02

相关推荐

php中抓取https页面 php抓取https url网页内容方法

在开发PHP 应用过程中,有时候需要获取https网页的内容,下面得方法,可以参考下。

直接用file_get_contents,会报错;

$url = ("); file_get_contents($url);

错误:

Warning: file_get_contents() [function.file-get-contents]: failed to open stream: No such file or directory in D:wampwwwgrabber_clientindex.php on line 3

用curl的方式是可以的:

$url = ();

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

$result = curl_exec($ch); print_r($result);

重点是以下两句:

代码如下:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

发布php中文网,转载请注明出处,感谢您的尊重!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。