如何使用 HTTPS 获取网站内容

发布于 2024-09-02 12:46:15 字数 1282 浏览 3 评论 0原文

使用 ssl ( HTTPs ) 的网站前: https://www.eb2a.com

1 - 我试图获取使用 file_get_contents 获取其内容,但不起作用并给出错误 ex :

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

echo $contents;
?>

2 - 我尝试使用 fopen,但不起作用并且给出错误 例如:

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

3 - 我尝试使用 CURL,但不起作用并给出空白页 例如:

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

任何人有任何想法吗?

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

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 - 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 - 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

any one have any idea ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无所的.畏惧 2024-09-09 12:46:15

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

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.

听不够的曲调 2024-09-09 12:46:15

网站重定向 301

将 url

https://www.eb2a.com/

更改为

https://www.eb2a.com

或如果仍然无法正常工作或需要将其与 / 一起使用,

请查看 LINK

使用curl重定向规则

web site redirect 301

change url

from

https://www.eb2a.com/

to

https://www.eb2a.com

or if still not working or need use it with /

loook at LINK

use curl redirect rules

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文