昨天给大家讲了同行账号获客,也就是同行博主下所有的视频下的评论通过匹配词来爬取用户信息,今天给大家讲讲某一个视频下如何爬取用户信息,其道理都是通过关键词查询评论。话不多说给大家上前端页面和后端代码。
/* * 视频任务 */ public function videoAction() { if (empty($this->breadcrumbs)) { //面包屑 $this->breadcrumbs = [ ['title' => 'D询盘获客', 'link' => '#dyxphk'], ['title' => '精准视频任务', 'link' => '/task/video'], ]; } $this->buildBreadcrumbs($this->breadcrumbs); $time_range = $this->request->getStrParam('time_range'); $keyword = $this->request->getStrParam('keyword'); $status = $this->request->getStrParam('status',0);//全部状态 $page = $this->request->getIntParam('page'); $index = $page * $this->count; $where = [ ['name' => 't_ds_id', 'oper' => '=', 'value' => $this->sid], ['name' => 't_platform', 'oper' => '=', 'value' => $this->platform],//抖音平台 ['name' => 't_type', 'oper' => '=', 'value' => 3],//任务 ]; if (!empty($time_range)) { $add_time_range_arr = explode('~', $time_range); $where[] = ['name' => 't_create_time', 'oper' => '>=', 'value' => strtotime($add_time_range_arr[0])]; $where[] = ['name' => 't_create_time', 'oper' => '<', 'value' => strtotime($add_time_range_arr[1]) + 86400]; } if (!empty($keyword)) { $where[] = ['name' => 't_name', 'oper' => 'like', 'value' => "%{$keyword}%"]; } if (!empty($status)) { $where[] = ['name' => 't_status', 'oper' => '=', 'value' => $status]; } $sort = [ 't_status' => 'ASC', 't_create_time' => 'DESC', ]; //获取账号列表 $task_model = new App_Model_Task_MysqlTaskStorage(); $video_list = $task_model->getList($where, $index, $this->count, $sort); $video_model = new App_Model_Douyin_MysqlXiansuoVideoStorage(); foreach ($video_list as &$item) { $item['video'] = $video_model->getRowById($item['t_related_id']); $item['video_link'] = $this->return_video_link($item['video']['xv_video_id']); $item['area_scope'] = empty($item['t_range_city']) ? '--' : join('-', json_decode($item['t_range_city'], 1)); } //计算分页 $all = $task_model->getCount($where); $page_libs = new Libs_Pagination_Paginator($all, $this->count, 'jquery', TRUE); $pageHtml = $page_libs->render(); //数据输出 $this->output['time_range'] = $time_range; $this->output['keyword'] = $keyword; $this->output['video_list'] = $video_list; $this->output['pageHtml'] = $pageHtml; $this->output['task_status'] = plum_parse_config('task_status', 'config'); $this->output['range_time'] = plum_parse_config('range_time', 'dydqt/project'); $this->output['range_sex'] = plum_parse_config('range_sex', 'dydqt/project'); $this->output_action_prefix(); $this->displaySmarty('dydqtshoppc/task/videoList.tpl'); }
把匹配到的用户信息填入我们的客户库里