[PHP] PHP抓取网络数据的6种常见方法 3 →→→→→进入此内容的聊天室

来自 , 2019-10-07, 写在 PHP, 查看 105 次.
URL http://www.code666.cn/view/2b45e8d6
  1. $data = array(
  2.         'foo'=>'bar',
  3.         'baz'=>'boom',
  4.         'site'=>'yuncode.net',
  5.         'name'=>'nowa magic');
  6.        
  7. $data = http_build_query($data);
  8.  
  9. //$postdata = http_build_query($data);
  10. $options = array(
  11.         'http' => array(
  12.                 'method' => 'POST',
  13.                 'header' => 'Content-type:application/x-www-form-urlencoded',
  14.                 'content' => $data
  15.                 //'timeout' => 60 * 60 // 超时时间(单位:s)
  16.         )
  17. );
  18.  
  19. $url = "http://yuncode.net/test2.php";
  20. $context = stream_context_create($options);
  21. $result = file_get_contents($url, false, $context);
  22.  
  23. echo $result;
  24.  

回复 "PHP抓取网络数据的6种常见方法 3"

这儿你可以回复上面这条便签

captcha