Method One:
$re file_get_contents ($url); Print_r ($re);
Method Two:
$ch = Curl_init ("http://www.jb51.net/" ); curl_setopt ( $ch , Curlopt_returntransfer, true ); curl_setopt ( $ch , Curlopt_binarytransfer, true ); $output = curl_exec ( $ch ) ; $fh = fopen ("out.html", ' W ' ) ; fwrite ( $fh , $output ); fclose ( $fh );
Method Three:
functionDfopen ($url,$limit= 0,$post= ",$cookie= ",$bysocket=FALSE,$ip= ",$timeout= 15,$block=TRUE,$encodetype= ' UrlEncode ') { $return= ' '; $matches=Parse_url($url); $host=$matches[' Host ']; $path=$matches[' Path ']?$matches[' Path ']. ($matches[' Query ']? ‘?‘.$matches[' Query ']: '): '/'; $port= !Empty($matches[' Port ']) ?$matches[' Port ']: 80; if($post) { $out= "POST$pathHttp/1.0\r\n "; $out. = "Accept: */*\r\n"; $out. = "accept-language:zh-cn\r\n"; $boundary=$encodetype= = ' UrlEncode '? ‘‘ : ‘;‘.substr($post, 0,Trim(Strpos($post, "\ n"))); $out.=$encodetype= = ' UrlEncode '? "content-type:application/x-www-form-urlencoded\r\n": "Content-type:multipart/form-data$boundary\ r \ n "; $out. = "User-agent:$_server[http_user_agent]\r\n]; $out. = "Host:$host\ r \ n "; $out. = ' Content-length: '.strlen($post)." \ r \ n "; $out. = "connection:close\r\n"; $out. = "cache-control:no-cache\r\n"; $out. = "Cookie:$cookie\r\n\r\n "; $out.=$post; } Else { $out= "GET$pathHttp/1.0\r\n "; $out. = "Accept: */*\r\n"; $out. = "accept-language:zh-cn\r\n"; $out. = "User-agent:$_server[http_user_agent]\r\n]; $out. = "Host:$host\ r \ n "; $out. = "connection:close\r\n"; $out. = "Cookie:$cookie\r\n\r\n "; } $fp= @Fsockopen(($ip?$ip:$host),$port,$errno,$errstr,$timeout); if(!$fp) { return‘‘; } Else { stream_set_blocking($fp,$block); Stream_set_timeout($fp,$timeout); @fwrite($fp,$out); $status=Stream_get_meta_data($fp); if(!$status[' Timed_out ']) { while(!feof($fp)) { if(($header= @fgets($fp)) && ($header= = "\ r \ n" | |$header= = "\ n")){ Break; } } $stop=false; while(!feof($fp) &&!$stop) { $data=fread($fp, ($limit= = 0 | |$limit> 8192? 8192:$limit)); $return.=$data; if($limit) { $limit-=strlen($data); $stop=$limit<= 0; } } } @fclose($fp); return $return; }}
PHP Impersonation Get Commit