PHP 利用fsockopen抓取页面后对内容做解析

----------------img---------------
<script src="//cdn.bootcss.com/jquery/3.0.0-beta1/jquery.js"></script>
<?php
$fp = fsockopen("www.example.com",
 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";

fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
 ?>

 <script type="text/javascript">
   $(function(){
     alert("ready");
     alert($("h1").html());
   });
 </script>



你可能感兴趣的:(PHP 利用fsockopen抓取页面后对内容做解析)