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