时间:2021-07-01 10:21:17 帮助过:53人阅读
代码如下:
$url = "http://www.gxlcms.com/";
$ctx = stream_context_create(array(
'http' => array('timeout' => 5,
'proxy' => 'tcp://60.175.203.243:8080',
'request_fulluri' => True,)
)
);
$result = file_get_contents($url, False, $ctx);
echo $result;
?>
代码如下:
function postPage($url)
{
$response = "";
$rd=rand(1,4);
$proxy='http://221.214.27.253:808';
if($rd==2) $proxy='http://222.77.14.56:8088';
if($rd==3) $proxy='http://202.98.123.126:8080';
if($rd==4) $proxy='http://60.14.97.38:8080';
if($url != "") {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
$response = curl_exec($ch);
if(curl_errno($ch)) $response = "";
curl_close($ch);
}
return $response;
}
代码如下:
$serverAddress = 'http://s.jb51.net';
//获得外域文件内容
$randomNumber = file_get_contents($serverAddress);
//输出内容
echo $randomNumber;
?>
以上就介绍了file_get_contents PHP下通过file_get_contents的代理使用方法,包括了file_get_contents方面的内容,希望对PHP教程有兴趣的朋友有所帮助。