首页  >  文章  >  后端开发  >  PHP采集、模拟登陆论坛小程序_PHP教程

PHP采集、模拟登陆论坛小程序_PHP教程

WBOY
WBOY原创
2016-07-13 17:39:24844浏览

//    吴燕军
//   采集程序2cto.com
set_time_limit(0);

//cookie保存目录
$cookie_jar = /tmp/cookie.tmp;

/*函数 ------------------------------------------------------------------------------------------------------------*/

//模拟请求数据
function request($url,$postfields,$cookie_jar,$referer){
$ch = curl_init();
$options = array(CURLOPT_URL => $url,
      CURLOPT_HEADER => 0,
      CURLOPT_NOBODY => 0,
      CURLOPT_PORT => 80,
      CURLOPT_POST => 1,
      CURLOPT_POSTFIELDS => $postfields,
      CURLOPT_RETURNTRANSFER => 1,
      CURLOPT_FOLLOWLOCATION => 1,
      CURLOPT_COOKIEJAR => $cookie_jar,
      CURLOPT_COOKIEFILE => $cookie_jar,
      CURLOPT_REFERER => $referer
);
curl_setopt_array($ch, $options);
$code = curl_exec($ch);
curl_close($ch);
return $code;
}

// 获取帖子列表
function getThreadsList($code){
preg_match_all(/

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn