例一:
复制代码 代码如下:
$cookie_jar = tempnam(''./tmp'',''cookie'');
$ch = curl_init(); curl_setopt($ch,CURLOPT_URL, ''http://******'');
curl_setopt($ch, CURLOPT_POST, 1);
$request = ''email_address=&password=&action='';
curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //把返回来的cookie信息保存在$cookie_jar文件中
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); //设定返回的数据是否自动显示
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //设定是否显示头信息
curl_setopt($ch, CURLOPT_HEADER, false); //设定是否输出页面内容
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_exec($ch);
curl_close($ch); //get data after login
例二:
复制代码 代码如下:
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, ''http://*****'');
curl_setopt($ch2, CURLOPT_HEADER, false);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_jar);
$orders = curl_exec($ch2);
echo '''';
echo strip_tags($orders);
echo '''';
curl_close($ch2); 实践证明很稳定:)
例三:
复制代码 代码如下:
set_time_limit(0);
function _rand() {
$length=26;
$chars = "0123456789abcdefghijklmnopqrstuvwxyz";
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
$string = '''';
for($i = 0; $i < $length; $i++) {
$string .= $chars[mt_rand(0, $max)];
}
return $string;
}
$HTTP_SESSION=_rand();
echo $HTTP_SESSION;
$HTTP_Server="www.baidu.com";
$HTTP_URL="/";
$ch = curl_init();
curl_setopt ($ch,CURLOPT_URL,"http://".$HTTP_Server.$HTTP_URL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
//curl_setopt($ch,CURLOPT_COOKIE,$HTTP_SESSION);
$res = curl_exec($ch);
curl_close ($ch);
print_r($res);
刷论坛代码:
1、抓cookies程序:
复制代码 代码如下:
$URL="http://w