php通过socket获取网页内容的简单示例,请看下面代码:
$url='www.phpernote.com'; $fp=fsockopen($url,80,&$errno,&$errstr,10); if(!$fp){ echo "$errstr ($errno)<br>\n"; }else{ fputs($fp,"GET / HTTP/1.0\nHost: ".$url."\n\n"); while(!feof($fp)){ echo fgets($fp,128); } fclose($fp); }