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

2019-05-26 11:23:17 浏览数 (1)

为什么80%的码农都做不了架构师?>>>

代码语言:javascript复制
----------------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.1rn";
$out .= "Host: www.example.comrn";
$out .= "Connection: Closernrn";

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

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

0 人点赞