PHP collection remote server content code
Method simulates a user's access to a Web page
function Readpr ($link, $url)
{
$fp = Fsockopen ($url, $errno, $errstr, 30);
if (! $fp)
{
echo "$errstr ($errno) n";
Exit (1);
}
Else
{
$out = "Get $link http/1.0rn";
$out. = "Host: $URLRN";
$out. = "user-agent:mozilla/4.0 (compatible; Googletoolbar 2.0.114.9-big; Linux 2.6) RN;
$out. = "Connection:closernrn";
Fwrite ($fp, $out);
do{
$line = fgets ($fp, 128);
}while ($line!== "RN");
$data = Fread ($fp, 8192);
Fclose ($FP);
return $data;
}
}//method Two uses Curl_init to read the Remote Web page content
function init ()
{
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
$file _contents = curl_exec ($ch);
Curl_close ($ch);
}
Method Three simplest use file_get_contents
function GetFiles ($value)
{
$get _file = @file_get_contents ($value);
}
Method four uses the fopen to collect the remote webpage content
function GetFiles ($value)
{
Return fopen ($value);
}