爬库脚本

来源:互联网 发布:源码绑定域名绑定ip 编辑:程序博客网 时间:2024/05/17 05:08
<?phpset_time_limit(0);$fileName = 'testx.txt';$startTime = '1';$endTime = '2';$link = mysql_connect('ip:port', 'user', 'password');if (!$link) {    die('Could not connect: ' . mysql_error());}mysql_select_db('dbname', $link) or die ('Can\'t use foo : ' . mysql_error());$res = mysql_query ( 'show tables;', $link);$return = array();$tables = array();while($row=mysql_fetch_array($res)) {      $return[] = $row;  }foreach( $return AS $key => $item ){   $table = $item[0];   if( strstr($table, 'table name') !== false ){      $tables[] = $table;   }}$baobiao = array();$sql = 'select 1,2  from ';foreach( $tables AS $table ){   $temp = $sql.$table.' where 1=1 and tieba_video_url != \'\' ';   $res = mysql_query ($temp, $link);      $str = '';   while($row=mysql_fetch_array($res)) {      if( $row['row_name'] > 0 ){         $post_id = $row['row_name'];         $str.=$post_id."_".$row['row_b']."\r\n";      }   }   file_put_contents($fileName,$str,FILE_APPEND);   usleep(1000);}mysql_close($link);echo "OK";
原创粉丝点击