Method simulates a user's access to a Web page
| The code is as follows |
Copy Code |
function Readpr ($link, $url)
{
$fp = Fsockopen ($url, $errno, $errstr, 30);
if (! $fp)
{
echo "$errstr ($errno)";
Exit (1);
}
Else
{
$out = "Get $link http/1.0";
$out. = "Host: $url";
$out. = "user-agent:mozilla/4.0 (compatible; Googletoolbar 2.0.114.9-big; Linux 2.6) ";
$out. = "Connection:close";
Fwrite ($fp, $out);
do{
$line = fgets ($fp, 128);
}while ($line!== "");
$data = Fread ($fp, 8192);
Fclose ($FP);
return $data;
}
} |
Method two uses Curl_init to read the content of the Remote Web page
| code is as follows |
copy code |
|
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 file_get_contents
Function GetFiles ($value)
{
$get _file = @file_get_contents ($value);
}
//method four use fopen to collect Remote Web page content
Function GetFiles ($value)
{
return fopen ($value);
} |