$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://www.yoururl.com/bbs/login.asp?action=chk";
//填入论坛的登陆页面地址
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$URL);
curl_setopt($ch,CURLOPT_REFERER,"http://www.hxfoods.com/bbs/login.asp");
//设置,访问页面的来源地址
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,'username=→→敢死队→&password=168168');
//分析登陆页面,把用户名,密码分别对应起来
curl_setopt ($ch, CURLOPT_HEADER,true);
//使能显示 http 头,
curl_exec($ch);
if (curl_errno($ch))
{
print curl_error($ch);