如何获取网站的内容使用HTTPS [英] how to get contents of site use HTTPS

查看:116
本文介绍了如何获取网站的内容使用HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ssl(HTTPs)排除网站: https://www.eb2a.com

ex of site using ssl ( HTTPs ) : https://www.eb2a.com

1 - 我试图使用file_get_contents获取其内容,但不工作,给出错误
例如:

1 - i tried to get its content using file_get_contents, but not work and give error ex :

<?php
$contents = file_get_contents("https://www.eb2a.com/");

echo $contents;
?>

2 - 我试图使用fopen,但不工作和给出错误
例如:

2 - i tried to use fopen, but not work and give error ex:

<?php
$url = 'https://www.eb2a.com/';
$contents = fopen($url, 'r');
echo "$contents";
?>

3 - 我试图使用CURL,但不工作,并给予 BLANK PAGE
例如:

3 - i tried to use CURL, but not work and give BLANK PAGE ex :

function cURL($url, $ref, $header, $cookie, $p){
$ch =  curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);    
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    
if ($p) {
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$result =  curl_exec($ch);
curl_close($ch);
if ($result){
    return $result;
}else{
    return '';
}
}

$file = cURL('https://www.eb2a.com/','https://www.eb2a.com/',0,0,null);
echo $file

任何人都有任何想法

推荐答案

要从安全协议 https 获取内容,您需要 openssl 从php.ini文件启用扩展和对此的身份验证。

To fetch the contents from secure protocal https, you need to have openssl extenstion enabled from php.ini file and the authentication for that matter.

这篇关于如何获取网站的内容使用HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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