基于PHP/CURL/codeIgniter的Spider Webbot爬虫[8]-预判网站支持压缩,使用压缩和数据库保存数据

预判压缩,若是支持压缩则优先使用php

$header[]="Accept-Encoding:compress,gzip";
curl_setopt($curl_session,CURLOPT_HTTPHEADER,$header);html

捕捉档案而且压缩范例web

include("LIB_http.php");session

// define the page
$target="http://xxx";
$ref="";
$method="GET";
$data_array="";
$web_page=http_get($target,$ref,$method,$data_array,EXCL_HEAD);curl

// 获得捕捉到的档案,而且进行压缩,而且输出压缩先后的大小
$unzip_size=strlen($webpage['FILE]);
$zip_size=strlen(gzcompress($web_page['FILE'],$compression_value=9));
//$noformat_size=strlen(strip_tags($web_page['FILE']));//strip_tags移除HTML标签
// 还能够添加trim移除全部空格url

输出一张显示用的HTML表格(size)spa


<!DOCTYPE html>
<html lang="en">
<head>

<title>Welcome to Omoikane</title>
</head>
<body>orm

Compression report for
Unzip zip
bytes bytes

</body>
</html>

htm

</body> </html>
相关文章
相关标签/搜索