代码拉取完成,页面将自动刷新
<?php
!defined('FRAMEWORK_PATH') && exit('Access Denied.');
/*
common_control from external core path = FRAMEWORK_EXTEND_PATH
*/
class index_control extends common_control {
function __construct(&$conf) {
parent::__construct($conf);
}
function on_index() {
$cache = CACHE::get('aaa');
// write cache
if ($cache === false) {
CACHE::set('aaa', $_SERVER, 5);
$cache = CACHE::get('aaa');
}
// read cache
VI::assign('cache', $cache);
VI::assign_value('test', 'this is VI::assign_value');
$hash = misc::form_hash();
$_REQUEST['FORM_HASH'] = $hash;
VI::display($this, 'index.htm');
}
public static function process_relation($list) {
//process $list
return $list;
}
public static function process_relation_item($item) {
$item['text'] = str_replace('魔爪', '小说', $item['text']);
return $item;
}
function on_spider() {
$key = C::G('key', '魔爪小说阅读器');
$url = 'http://www.sogou.com/web?query=' . urlencode($key) . '&ie=utf8';
$html = spider::GET($url, '', array('Referer' => 'http://www.sogou.com/'));
$result = spider::match($html, array(
'relation_text' => 'DOM::#hint_container',
'relation_list' => array(
//selector
'selector' => '.hintBox a',
'link' => 'DOM:abs-href:',
'text' => 'DOM:text:',
//process_item
'process_item' => 'index_control::process_relation_item',
//process
'process' => 'index_control::process_relation',
),
'keys' => array(
'cut' => '相关搜索</caption>(*)</tr></table>',
'pattern' => '#id="sogou_\d+_\d+">(?<key>[^>]*?)</a>#is',
),
'first_summary' => array(
'pattern' => array(
'<!--summary_beg-->(*)<!--summary_end-->',
),
'process' => array(
'spider::no_html'
),
),
'first_title' => 'DOM::a[name=dttl]:first',
'first_link' => 'name="dttl" target="_blank" href="(*)"',
)
, array('url' => $url));
// like first_summary
$result['first_title'] = strip_tags($result['first_title']);
VI::assign('result', $result);
$this->show('index');
}
function on_fetch() {
$url = C::P('url', 'https://baidu.com/');
$html = spider::GET($url);
VI::assign('url', $url);
VI::assign('html', $html);
// default show {$control}_{$action}.htm
$this->show();
}
}
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。