Maison  >  Article  >  développement back-end  >  采集程序php

采集程序php

WBOY
WBOYoriginal
2016-06-23 14:31:30838parcourir

//   采集程序php
set_time_limit(0);

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

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

//模拟请求数据Fashion jewelry
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('/

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Article précédent:PHP自动部署Article suivant:PHP和MySQL入门(3)