1. <?php      
  2. // --------------------------------------------------------------------------   
  3. // 文件名称   :  curl_post.php   
  4. // 文件说明   :  通过PHP的curl函数模拟post,支持模拟cookie及useragent   
  5. // 源码作者   :  孤魂 (www.kalvin.cn)   
  6. // --------------------------------------------------------------------------   
  7.       
  8.       
  9. //将$url中 http://www.kalvin.cn/index.php 更换成你Post的地址   
  10. $url='http://www.kalvin.cn/index.php';   
  11.   
  12. //目标来源页面   
  13. $referer='http://www.kalvin.cn/';  
  14.       
  15. //如果目标网站需要登录,可以在这里写入模拟的Cookie值   
  16. $cookie='';   
  17.       
  18. //将$post_data中写入你所截取的数据包,可以使用Winsock Expert截取数据包   
  19. $post_data='author=孤魂&date=2008.06.04';   
  20.       
  21. //部分网站验证浏览器信息,可以在下面模拟浏览器,可以直接将USERAGENT复制到这里面   
  22. $useragent='';   
  23.       
  24. //下面的内容禁止修改   
  25. $ch = curl_init();   
  26. curl_setopt($ch, CURLOPT_POST, 1);   
  27. curl_setopt($ch, CURLOPT_HEADER, 0);   
  28. curl_setopt($ch, CURLOPT_URL,$url);   
  29. curl_setopt($ch, CURLOPT_REFERER, $referer);   
  30. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);   
  31. curl_setopt($ch, CURLOPT_COOKIE,$cookie);   
  32. curl_setopt($ch, CURLOPT_USERAGENT,$useragent);   
  33. $result = curl_exec($ch);   
  34. ?>  

相关文章:

  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-27
  • 2021-08-24
  • 2021-08-09
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2021-07-18
相关资源
相似解决方案