function fastpick_evo_test() { pload('F:spider'); $id = intval($_GET['id']); $rules_info = fastpick_info($id, '*', 'evo'); $content = get_contents($rules_info['detail_ID_test']); $re = evo_rules_get_article($content, $rules_info); show_pick_window($re['title'], $re['content'], array('w' => 650, 'h' => '460', 'f' => 1)); }
function cloud_match_rules($get_type, $url, $content) { global $_G; pload('F:fastpick'); $setting = get_pick_set(); $pick_config = $_G['cache']['evn_milu_pick']['pick_config']; $server_cache_time = $pick_config['index_server_cache_time']; if ($get_type == '3') { //智能学习规则索引过期时间比较短 $server_cache_time = $pick_config['evo_index_server_cache_time']; } $milu_set = pick_common_get(); if ($setting['open_cloud_pick'] != 1) { return FALSE; } pload('F:copyright'); $host_info = GetHostInfo($url); $domain = $host_info['host']; $domain_hash = md5($domain); $url_temp = preg_replace('/\\d+/', '', $url); $arr_temp = parse_url($url_temp); $path_hash = md5($arr_temp['path']); $over_dateline = $_G['timestamp'] - $server_cache_time; $count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('strayer_searchindex') . " WHERE domain_hash='" . $domain_hash . "' AND path_hash='" . $path_hash . "' AND type='" . $get_type . "3' AND dateline > {$over_dateline}"), 0); //3是服务端 4是本地的缓存 if ($count) { return FALSE; } $args = array('get_type' => $get_type, 'url' => $url); $rpcClient = rpcClient(); $client_info = get_client_info(); $re = $rpcClient->cloud_match_rules($args, $client_info); if (is_object($re) || $re->Number == 0) { if ($re->Message) { return milu_lang('phprpc_error', array('msg' => $re->Message)); } $re = (array) $re; } $data = array(); if ($re['data_type'] == 1) { //返回规则 $rules_info = $re['data']; if ($get_type == 3) { $data = evo_rules_get_article($content, $rules_info); } else { $data = rules_get_article($content, $rules_info); } if ($data || $data['content'] && $get_type == 3) { //规则验证有效,下载到本地 if ($get_type == 3) { $data_id = import_evo_data($rules_info); } else { $data_id = import_fastpick_data($rules_info); } if ($data_id) { //先清除之前的索引 DB::query('DELETE FROM ' . DB::table('strayer_searchindex') . " WHERE domain_hash='" . $domain_hash . "' AND path_hash='" . $path_hash . "'"); add_search_index($domain_hash, $path_hash, $get_type . '4', $data_id); //添加索引 } } } else { if ($re['data_type'] == 2) { //返回内容 $data = $re['data']; } else { //一无所获,那也要告诉客户端,别再骚扰服务端了 add_search_index($domain_hash, $path_hash, $get_type . '3', 0); } } return $data; }
function evo_get() { $milu_set = pick_common_get(); $get_type = 3; $rules_info = match_rules($this->url, $this->str, $get_type, 0); //从本地学习到的规则获取 if (!is_array($rules_info) || !$rules_info) { $get_type = 5; //只从详细页搜索 $rules_info = match_rules($this->url, $this->str, $get_type, 0); //尝试从本地内置规则取 } $data['evo'] = 2; if (!is_array($rules_info) || !$rules_info) { $data = cloud_match_rules(3, $this->url, $this->str); //从服务器端获取 if (!$data['content']) { return array(); } if (!$data['title']) { $re_title = $this->get_title(); if ($re_title['html']) { $data['title'] = $re_title['html']; } } if ($data['content']) { return $data; } } if (!$rules_info) { return array(); } $data = evo_rules_get_article($this->str, $rules_info); if (!$data['content']) { //如果匹配到规则,但是又获取不到内容,证明规则出错了,记录起来 pload('F:fastpick'); write_evo_errlog($data, $this->url, $rules_info); } if (!$data['title']) { $re_title = $this->get_title(); if ($re_title) { $data['title'] = $re_title['html']; } } if ($rules_info['detail_ID_test'] != $this->url) { DB::update("strayer_evo", array('hit_num' => $rules_info['hit_num'] + 1), array("id" => $rules_info['id'])); } return $data; }