TypechoJoeTheme

至尊技术网

统计
登录
用户名
密码
/
注册
用户名
邮箱
搜索到 4 篇与 的结果
2024-01-05

php curl无法获得https网页内容

php curl无法获得https网页内容
程序员最经常使用的curl,在php下面也是经常用的到。但是,博主友情提示您:用curl获取https的网页内容的时候,也是需要用到证书的。而这么多年,估计大家从来都没有察觉过任何更新证书的动作,证明这可能是有自动renew操作的。而目前博主手头的centos系统,却存在有使用curl无法获取https内容的问题。利用curl或者file_get_contents获取远程http的内容时,成功。但是获取https的内容时,失败。错误提示文字类似于:SSL operation failed with code 1. OpenSSL Error messages: error:14090086: SSL routines:ssl3_get_server_certificate:certificate vertify failed 解决方法1、保证php.ini里面的openssl扩展肯定要打开。这个操作比较基础,不做赘述。extension=openssl.so 2、查看一下openssl证书的默认位置,检测openssl的证书位置的代码:php -r "print_r(o...
2024年01月05日
1,715 阅读
2 评论
2020-11-04

解决php中遇到的failed-to-open-stream:-HTTP-request-failed!

解决php中遇到的failed-to-open-stream:-HTTP-request-failed!
当使用php5自带的file_get_contents方法来获取远程文件的时候,有时候会出现file_get_contents(): failed to open stream: HTTP request failed!这个警告信息。解决方法:file_get_contents 和 curl 这俩强悍的函数,在远程抓取时候相当有用处.不过一些网站会根据来访ip是否携带user_agent来判断是正常的浏览器客户端还是机器.所以,我们的任务就是给他们伪造user_agent。file_get_contents伪造user_agent 方法如下:ini_set('user_agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'); curl伪造user_agent的方法:curl_setopt($c, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WO...
2020年11月04日
919 阅读
0 评论
2020-11-04

php获取网页内容,curl 发起get、post请求

php获取网页内容,curl 发起get、post请求
获取指定的内容,主要还是用到preg_match_all()函数,只执行一次正则表达式也可以用preg_match()函数!1.html代码如下<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Cache-Control" content="no-cache"> <title>测试</title> </head> <body> <div class="box">测试</div> <div class="box">测试2</div> <div class="box&qu...
2020年11月04日
1,044 阅读
0 评论

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. 强强强
    2025-04-07
  2. jesse
    2025-01-16
  3. sowxkkxwwk
    2024-11-20
  4. zpzscldkea
    2024-11-20
  5. bruvoaaiju
    2024-11-14

标签云