我使用php文件类函数fopen操作的
其他详细请参考php中文手册https://www.php.net/manual/zh/function.fopen.php
fopen的filename也就是第一个参数被当成一个URL,第二个参数是mode为访问类型 我这里使用的是 r:只读方式打开
$readcontents = fopen('https://www.baidu.com/', 'r');
stream_get_contents:读取资源流到一个字符串
$contents = stream_get_contents($readcontents);
fclose:关闭一个已打开的文件指针
fclose($readcontents);
最后只需要把内容展示出来就可以了(以下是所有代码)
$readcontents = fopen("https://www.baidu.com/", "r");
$contents = stream_get_contents($readcontents);
fclose($readcontents);
echo $contents;