예제 #1
0
    $page = $_GET['page'];
} else {
    $page = 1;
}
include './includes/phpQuery.php';
phpQuery::newDocumentFile(get_base() . 'fetch.php?word=' . urlencode($word) . '&page=' . $page);
$list = pq('.g');
foreach ($list as $li) {
    $data['name'][] = pq($li)->find('.r')->find('a')->html();
    $data['_url'][] = pq($li)->find('.r')->find('a')->attr('href');
    $data['desc'][] = pq($li)->find('.s')->find('.st')->html();
}
$data['num'][0] = pq('#resultStats')->html();
$data['num'][1] = get_number($data['num'][0]);
foreach ($data['_url'] as $key => $value) {
    $data['url'][] = get_true_url($data['_url'][$key]);
}
foreach ($data['url'] as $key => $value) {
    if (substr($value, 0, 1) == '/') {
        unset($data['url'][$key], $data['name'][$key], $data['desc'][$key]);
    }
}
include './includes/page.class.php';
$pager = new Page(10, $data['num'][1], $page, 10);
$pager_html = $pager->show();
function get_true_url($string)
{
    $start = '/url?q=';
    $end = '&sa=';
    if (($start_pos = strpos($string, $start)) !== false) {
        if ($end) {
예제 #2
0
require dirname(__FILE__) . '/functions.php';
require dirname(__FILE__) . '/includes/simple_html_dom.php';
require dirname(__FILE__) . '/includes/page.php';
header("Content-Type: text/html;charset=utf-8");
if (!isset($_GET['word'])) {
    header('Location: ' . get_base());
} elseif ($_GET['word'] == '') {
    header('Location: ' . get_base());
} else {
    $word = $_GET['word'];
}
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = 1;
}
$html = file_get_html(get_base() . 'fetch.php?word=' . urlencode($word) . '&page=' . $page);
foreach ($html->find('.g') as $i => $li) {
    $data[] = array('title' => $li->find('.r', '0')->find('a', '0')->plaintext, 'original_url' => $li->find('.r', '0')->find('a', '0')->href, 'content' => $li->find('.s', '0')->find('.st', '0')->plaintext);
    $data[$i]['url'] = get_true_url($data[$i]['original_url']);
}
$count['word'] = $html->find('#resultStats', '0')->plaintext;
$count['number'] = get_number($count['word']);
foreach ($data as $key => $value) {
    if (substr($value['url'], 0, 1) == '/') {
        unset($data[$key]);
    }
}
$pager = new Page(10, $count['number'], $page, 10);
$pager_html = $pager->show();
include './templates/results.html';