Exemplo n.º 1
0
    $api_left = api_left($c);
    $msg = "api_left[{$api_left['user']}, {$api_left['ip']}].\tid_num: {$id_num}\t";
    // debug
    //    echo $msg;
    write_line($msg);
    if ($api_left['ip'] < 50) {
        // 此处应该使用10*user_count
        $msg = "ip remain hits lower than 50({$api_left['ip']}), exit.\n";
        //        echo $msg;
        write_line($msg);
        exit;
    }
    // 检测当前user剩余api hits
    $api_left = api_left($c);
    if ($api_left['user'] < 10) {
        $c = change_token($c, $dbo);
    }
    // 抓取用户信息
    $user_info = get_user_info($c, $id_val);
    // 以数组的形式返回数据
    write_info($user_info, $dbo);
    // 写数据库,或者别的
    sleep(1);
    // 假定token充足,一个ip一小时抓333个用户信息,每小时前10min后10min均睡眠。
}
$msg = '五千粉丝抓完了,请换一个源用户,或者从cron中清除我';
//mail_to_master();
/*
 *  负责写数据库,尚未完成
 *  以输出数据模拟
 */
        $api_left = api_left($c);
        $msg = "api_left[{$api_left['user']}, {$api_left['ip']}].\tid_num: {$id_num}\t({$sid})";
        // debug
        //    echo $msg;
        write_line_with_time_and_newline($msg);
        if ($api_left['ip'] < 50) {
            // 此处应该使用10*user_count
            $msg = "ip remain hits lower than 50({$api_left['ip']}), exit.";
            //        echo $msg;
            write_line_with_time_and_newline($msg);
            exit;
        }
        // 检测当前user剩余api hits
        $api_left = api_left($c);
        if ($api_left['user'] < 10) {
            $c = change_token($c, $dbo, 15, true, true);
        }
        // 抓取用户信息
        $user_info = get_user_info($c, $id_val, $sid);
        // 以数组的形式返回数据
        write_info($user_info, $dbo);
        // 写数据库,或者别的
        sleep(1);
        // 假定token充足,一个ip一小时抓333个用户信息,每小时前10min后10min均睡眠。
        // 目前的情况是这样的:
        // 每十五分钟运行一次本文件,每次运行三五分钟(视token数量而定)
        // 在这之间,api限制就已经重置了。
    }
}
$sub = '微动力爬虫提示';
$time = date('H:i:s M j');
Exemplo n.º 3
0
    }
}
// check admin pass is not default
$pass_check_sql = 'SELECT * FROM users WHERE login = "******"';
$pass_check_result = mysql_q($pass_check_sql);
$pass_check = mysql_fetch_array($pass_check_result);
if ($pass_check['password'] == '21232f297a57a5a743894a0e4a801fc3') {
    $output_panel_info .= $lang['a_pass_default'] . '<br />';
}
/* #########
 * # TOKEN #
 */
#########
if ($option == 'token') {
    if (isset($_POST['new_token'])) {
        $new_token = change_token();
        $output_panel_info .= $lang['a_token_changed'] . '<br />';
    } else {
        $new_token = $setting['token'];
    }
    $output_panel .= '
        <table class="table">
            <tr><td>Token:</td><td class="bold orange">' . $new_token . '</td></tr>
        </table><br />
        <form action="admin.php?option=token" method="post">
        <input type="hidden" name="new_token" />
        <input type="submit" value="' . $lang['a_token_change'] . '" />
        </form>
    ';
}
/* ##########