您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

使用PHP简单网页抓取和内容分析

2024/4/11 20:36:53发布14次查看
网页
没事的时候想抓取点网页看看,也不太懂,只是玩玩,写了点代码,聊以娱乐。
稍微有点意义的函数是:get_content_by_socket(), get_url(), get_content_url(), get_content_object 几个函数,也许能够给你点什么想法。
'\\s]+)[\'>]*\s*/i;
    $reg = '/^(down.*?\.html)$/i';
    preg_match_all ($rex, $file_contents, $r);
    $result = ; //array();
    foreach($r as $c){
        if (is_array($c)){
            foreach($c as $d){
                if (preg_match($reg, $d)){ $result .= $host_url . $d.\n; }
            }
        }
    }
    return $result;
}
//获取指定内容中的多媒体文件
function get_content_object($str, $split=|--:**:--|){    
    $regx = /href\s*=\s*['\]*([^>'\\s]+)[\'>]*\s*(.*?)/i;
    preg_match_all($regx, $str, $result);
    if (count($result) == 3){
        $result[2] = str_replace(多媒体: , , $result[2]);
        $result[2] = str_replace(, , $result[2]);
        $result = $result[1][0] . $split .$result[2][0] . \n;
    }
    return $result;
}
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product