<?php header("Content-type: text/html; charset=utf-8"); require_once 'database.php'; //set_time_limit(0); //ignore_user_abort(); function writelog($log){ $log_file="rizhi.txt"; $fp = fopen($log_file,'a'); fwrite($fp,date("Y-m-d H:i:s",time())." ".$log."\r\n"); fclose($fp); } function writelog2($log){ $log_file="QQMAIL.txt"; $fp = fopen($log_file,'a'); fwrite($fp,$log."\r\n"); fclose($fp); } ignore_user_abort(); // 即使Client断开(如关掉浏览器),PHP脚本也可以继续执行. set_time_limit(0); // 执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无限制的执行下去 $bb = 0 ; writelog('开始采集!'); echo '开始采集!<br><hr>'; for($nl=24;$nl<=30;$nl++){//年龄 $nl++; $nl2=$nl +1; for($yue=1;$yue<=12;$yue++){//月 for($ri=1;$ri<=31;$ri++){//日 for($i=0;$i<100;$i++){//页数 $jishu =$i+1; echo "<font color = red>最低年龄:".$nl."最高年龄:".$nl2." ".$yue."月".$ri."日 ".$jishu."%</font>"; echo "<br>"; writelog("最低年龄:".$nl."最高年龄:".$nl2." ".$yue."月".$ri."日 第".$i."页"); $url="http://soren.qzone.qq.com/cgi-bin/soren/cgi_userinfo_search?sex=-1&a1=".$nl."&a2=".$nl2."&pv=11&ct=1100&hp=0&hc=0&at=-1&month=".$yue."&day=".$ri."&mr=-1&bt=-1&cr=&cn=&cap=0&cac=0&idol=&game=&it=&sport=&book=&tv=&cloth=&cosm=&place=&interest=&begin=".$i."&bSimple=0"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10); $content = curl_exec($ch); preg_match_all('/id=\"portrait_(.*?)\" onclick/is',$content,$qq); foreach($qq[1] as $value){ $coolaj = trim($value)."@qq.com"; $sql = "select * from mail where mails = '".$coolaj."'"; $rs2 = mysql_query($sql, $connect) or die("Invalid query: " . mysql_error()); $cool = mysql_fetch_row ($rs2); if(is_array($cool)){ writelog("插入失败->".$coolaj."已经存在!"); }else{ $rs = mysql_query("insert into mail VALUES('','".$coolaj."','".$i."','QQ采集')", $connect) or die("Invalid query: " . mysql_error()); if($rs){ $bb++; echo $showtime=date("Y-m-d H:i:s"); echo "插入<font color=red>第".$bb."个</font><font color=blue>".$coolaj."</font>成功!<br>"; writelog("插入第".$bb."个".$coolaj."成功!"); writelog2($coolaj); }else{ writelog("插入".$coolaj."失败!"); } } } } } } } echo "<script>alert('采集完成!')</script>";
<?php $_POST=sql_injection($_POST); $_GET=sql_injection($_GET); function sql_injection($content) { if (get_magic_quotes_gpc()) { if (is_array($content)) { foreach ($content as $key=>$value) { $content[$key] = str_replace("'","\"",stripslashes($value)); } } else { $content[$key] = str_replace("'","\"",stripslashes($content)); } } return $content; } $hostname_conn = "localhost"; $database_conn = "test"; $username_conn = "root"; $password_conn = ""; $connect = mysql_pconnect($hostname_conn, $username_conn, $password_conn,true) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_conn, $connect); mysql_query("set NAMES 'UTF8'"); date_default_timezone_set('PRC'); ?>