public function init_tieba() { $url = "http://tieba.baidu.com/f/like/mylike?&pn=1"; $html = $this->request("get", $url); $html = mb_convert_encoding($html, "UTF-8", "gbk,gb2312,UTF-8"); echo "--geting html---\n"; preg_match('/\\<a href="\\/f\\/like\\/mylike\\?\\&pn=(.*?)"\\>尾页\\<\\/a\\>/', $html, $total); $total = $total[1]; $names = []; echo "--geting title---\n"; for ($i = 1; $i <= $total; $i++) { $url = "http://tieba.baidu.com/f/like/mylike?&pn=" . $i; $names = array_merge($names, $this->fetch_tieba($url)); } echo "--insert database---\n"; foreach ($names as $k => $v) { if (!tieba::where(['name' => $v])->get()->first()) { \tieba::create(['name' => $v]); } } echo "-- down insert ---\n"; exit(__FILE__ . __LINE__); }
<thead> <tr> <th>ID</th> <th>名字</th> <th>状态</th> </tr> </thead> <tbody> <?php $robot_list = get_robot_list(); if (empty($robot_list)) { echo '<div class="am-animation-scale-up am-text-danger am-text-center">没有机器人,请添加</div>'; } else { foreach ($robot_list as $k) { $content = "<tr><td>{$k['id']}</td><td>{$k['name']}</td><td>"; if (tieba::islogin($k['bduss']) === true) { $content .= '<span class="am-icon-check"></span></td></tr>'; } else { $content .= '<span class="am-icon-close"></span></td></tr>'; } echo $content; } } ?> </tbody> </table> <p>PS:只会获取ID为1的消息,其他帐号为辅助小号</p> </div> </div> <div class="am-btn-group" data-am-scrollspy="{animation:'fade',repeat: false}"> <button type="button" class="am-btn am-btn-secondary" id="add-robot">添加</button>
} return; } if ($_GET['do'] == 'editrobot') { if (empty($_GET['bduss'])) { echo '请输入BDUSS'; return; } elseif (empty($_GET['id'])) { echo '请输入ID'; return; } elseif (tieba::islogin($_GET['bduss']) === false) { echo '无效的BDUSS'; return; } else { $name = tieba::getun($_GET['bduss']); if (empty($name)) { echo '无法获取百度ID'; return; } if ($_GET['id'] == 1) { set_pid(tieba::getpid($_GET['bduss'], 'reply'), 'reply'); set_pid(tieba::getpid($_GET['bduss'], 'at'), 'at'); } if (set_robot($_GET['id'], $name, $_GET['bduss']) === true) { echo '更新成功'; } else { echo '更新失败'; } } } /*PHP END*/