Example #1
0
    $task_status = $v['status'];
    $chatset = $v['charset'];
    $rules = array();
    if ($task_status == 'yes') {
        system("echo -e '开始抓取\\033[34m[" . $v['node_name'] . "]\\033[0m...'");
        $rules = json_decode($v['link_rules'], true);
        // 获取内容的链接
        $link_list = array();
        $link_list = get_link_list($rules['list_rule']);
        $link_list_count = count($link_list);
        system("echo -e '获取到\\033[32m[" . $link_list_count . "]\\033[0m个列表列表链接,准备获取文章链接...'");
        foreach ($link_list as $vo) {
            system("echo -e '获取列表内容链接: \\033[32m" . $vo . "\\033[0m'");
            $content = '';
            $content = http_client_request($vo);
            if ($chatset != 'utf-8') {
                iconv($chatset, "UTF-8", $content);
            }
            // print_r($content);exit;
            $target_urls = array();
            $target_urls = get_content_url_list($content, $rules['list_area']);
            // 探测链接失败
            if (empty($target_urls)) {
                system("echo -e '探测链接列表失败: \\033[31m" . $vo . "\\033[0m'");
                $result_errr = insert_log($vo, '探测链接列表失败');
            } else {
                insert_urls($target_urls, $task_list_id, true);
            }
        }
    }
}
Example #2
0
<?php

include 'simple_html_dom.php';
include 'db.php';
include 'head.php';
// Connect to the database
$conn = connect($config);
if (!$conn) {
    die('Problem connecting to the db.');
}
include 'content.php';
if (isset($_POST['submit-btn'])) {
    insert_urls($conn);
}
if (isset($_POST['showimages'])) {
    show_images($conn);
}
if (isset($_POST['cleardb'])) {
    clear_db($conn);
    echo '<p id="content">Database cleared</p>';
}
include 'footer.php';