1、curl方式獲取
<?php
$a = 'http://www.888.com/123.html';
$ch = curl_init($a);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');
$f = curl_exec($ch);
echo $f;
地址:https://gitee.com/jianwicn/mixed/raw/master/taobao
2、file_get_contents獲取
<?php
$a = 'http://www.888.com/123.html';
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>
"Accept-language: zh-cn\r\n" .
"User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; 4399Box.560; .NET4.0C; .NET4.0E)" .
"Accept: *//*"
)
);
$ctx = stream_context_create($opts);
$x = file_get_contents($a,false,$ctx);
echo $x;
下載地址:https://gitee.com/jianwicn/mixed/raw/master/file_get_contents