Browse Source

Merge pull request '查看抓取结果' (#50) from wpd_get2 into master

Reviewed-on: #50
pull/52/head
pengda 5 days ago
parent
commit
9e73bc8129
  1. 9
      control/weibo.php
  2. 25
      model/mWeiboBehavior.php

9
control/weibo.php

@ -87,12 +87,13 @@ class weibo extends publicBase {
public function ajax_get_spider_list() {
$date = trim($this->post('date'));
$uid = trim($this->post('uid'));
$cur_page = $this->post('currentPage') ? $this->post('currentPage') : 1;
$page_size = $this->post('pageSize') ? $this->post('pageSize') : 20;
$obj = new mWeiboBehavior();
$list = $obj->getSpiderBehavior($date, $cur_page, $page_size);
$total = $obj->getSpiderBehaviorTotal($date);
$list = $obj->getSpiderBehavior($date, $uid, $cur_page, $page_size);
$total = $obj->getSpiderBehaviorTotal($date, $uid);
$rdata = array(
'total' => $total,
@ -133,14 +134,14 @@ class weibo extends publicBase {
public function ajax_update_cookie() {
$cookie = trim($this->get('cookie'));
if(empty($cookie)) $this->ajax_json(false, '参数错误');
if (empty($cookie)) $this->ajax_json(false, '参数错误');
$type = $this->get('type') + 0;
$obj = new mWeiboBehavior();
$robj = $obj->initRedis();
$robj->set(_RC_WEIBO_LOGIN_COOKIE, $cookie);
if($type == 0){
if ($type == 0) {
shell_exec("nohup /usr/bin/php /data1/www/zhishiku.yizherenxin.cn/queue/crontab/spider_behavior_data.php > /dev/null 2>&1 &");
$this->ajax_json(true, '设置成功');
}

25
model/mWeiboBehavior.php

@ -36,13 +36,24 @@ class mWeiboBehavior extends mBase {
return $this->obj->delete($this->tbl_delta, array('sql' => "`date`<?", 'vals' => array($date)));
}
public function getSpiderBehavior($date, $page_num, $page_size) {
public function getSpiderBehavior($date, $uid, $page_num, $page_size) {
$where = array('sql' => "`date`=?", 'vals' => array($date));
if ($uid > 0) {
$where['sql'] .= " AND `uid`=?";
$where['vals'][] = $uid;
}
$offset = ($page_num - 1) * $page_size;
return $this->obj->selectAll($this->tbl_data, array('sql' => "`date`=?", 'vals' => array($date)), 'created_at desc', array($offset, $page_size));
return $this->obj->selectAll($this->tbl_data, $where, 'created_at desc', array($offset, $page_size));
}
public function getSpiderBehaviorTotal($date) {
return $this->obj->count($this->tbl_data, array('sql' => "`date`=?", 'vals' => array($date)));
public function getSpiderBehaviorTotal($date, $uid) {
$where = array('sql' => "`date`=?", 'vals' => array($date));
if ($uid > 0) {
$where['sql'] .= " AND `uid`=?";
$where['vals'][] = $uid;
}
return $this->obj->count($this->tbl_data, $where);
}
public function getHotBehavior($type, $sdate, $edate, $page_num, $page_size) {
@ -75,11 +86,11 @@ class mWeiboBehavior extends mBase {
$weibo_list = array_column($weibos, null, 'wid');
$weibo_user = $GLOBALS['WEIBO_USER_LIST'];
foreach ($res as &$re){
foreach ($res as &$re) {
$weibo = isset($weibo_list[$re['wid']]) ? $weibo_list[$re['wid']] : array();
$re['uname'] = empty($weibo)? $weibo_user[WEIBO_USER_ZHANG] : $weibo_user[$weibo['uid']];
$re['title'] = empty($weibo)? '无文字展示' : $weibo['text'];
$re['uname'] = empty($weibo) ? $weibo_user[WEIBO_USER_ZHANG] : $weibo_user[$weibo['uid']];
$re['title'] = empty($weibo) ? '无文字展示' : $weibo['text'];
$re['url'] = sprintf(WEIBO_DETAIL_URL, $re['wid']);
}
return $res;

Loading…
Cancel
Save