1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > PHP中file_get_contents函数抓取https地址出错的操作(两种方法)

PHP中file_get_contents函数抓取https地址出错的操作(两种方法)

时间:2022-10-06 18:42:30

相关推荐

PHP中file_get_contents函数抓取https地址出错的操作(两种方法)

php教程|php手册

file_get_contents,fiddler_抓取ht

php教程-php手册

在线购物系统 源码,ubuntu引入yum仓库,网络蜘蛛爬虫喜欢,宜昌php,红河seo培训lzw

本文通过两种方法解决PHP中file_get_contents函数抓取https地址出错,需要的朋友可以参考下

家庭财务管理系统源码,vscode发布留言板代码,ubuntu jdk更新,好用的tomcat版本,夏天 爬虫 黑色,php pear教程,中山整合营销seo外包lzw

网狐带内核源码,使用Ubuntu单系统,飞机反爬虫视频,php全栈开发教程电子书外包,昌平seo培训lzw

方法一:

在php中,抓取https的网站,,提示如下的错误内容:

Warning: file_get_contents() [function.file-get-contents]: failed to open stream: Invalid argument in I:Webmyphpa.php on line 16

打开php.ini文件找到 ;extension=php_openssl.dll ,去掉双引号”;” ,重启web服务器即可。

apache服务器的话,可以同时启用mod_ssl模块测试。

如果不方便修改服务器配置,可以参考使用如下的函数来解决:

代码示例:

<?php//file_get_contents抓取https地址内容function getCurl($url){$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);$result = curl_exec($ch);curl_close ($ch);return $result;}

方法二:

在php中,利用file_get_contents函数抓取url是https开头的网站网页内容时,会出现类似下面的错误警告:

Warning: file_get_contents(https://127.0.0.1/index.php) [function.file-get-contents]: failed to open stream: Invalid argument in E:\website\blog\test.php on line 25

打开php.ini找到 ;extension=php_openssl.dll ,去掉双引号”;” ,重启web服务器即可。

apache的可以同时启用mod_ssl模块测试

以上内容给大家分享了两种方法解决PHP中file_get_contents函数抓取https地址出错,希望对大家有所帮助。

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