PHP CURL获取https页面的内容 [英] PHP CURL to get contents of a https page

查看:164
本文介绍了PHP CURL获取https页面的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例网址:
https ://www.tescogoldexchange.com/gold-calculator.aspx?carat = 9& weight = 1& ref = miniQuote

我想使用cURL以获取HTTPS页面的内容。

I am trying to use cURL to get the contents of an HTTPS page.

问题是我无法抓取文档,我不知道为什么。

Problem is that I am not able to grab the document and I have no idea why.

    function download_page($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");

    return curl_exec($ch);
}


推荐答案

同一问题这家伙正在进入。而且,他似乎已经固定了。问题可能是关于SSL证书的协商,以及cURL应该如何告知服务器正在发送的证书,可以信任。

You're likely running into the same issue this guy is running into. And, he seems to have fixed it. The problem probably is the negotiation about the SSL certificate and how cURL should tell that the certificate the server is sending, can be trusted.

这篇关于PHP CURL获取https页面的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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