July 2, 2015 分类: DHTML     作者: hoverlees     留言: 发表
<?php
if($argc!=2){
	echo "usage: php har_extractor.php <archive file name>";
	exit();
}

$urlBase="http://a.b.com/";
$archiveFileName=$argv[1];
$data=file_get_contents($archiveFileName);
$archive=json_decode($data);
$entries=$archive->log->entries;
for($i=0;$i<count($entries);$i++){
	$entry=$entries[$i];
	$filePath=str_replace($urlBase,'',$entry->request->url);
	if(strlen($filePath)==strpos($filePath,'/')+1) $filePath.="index.html";
	$fileDir=dirname($filePath);
	$fileName=basename($filePath);
	if(strpos($fileName,'?')!==false) $fileName=substr($fileName,0,strpos($fileName,'?'));
	if($fileName=='') $fileName='index.html';
	if(!file_exists($fileDir)) mkdir($fileDir,0777,true);
	$encoding=$entry->response->content->encoding;
	
	$data=$entry->response->content->text;
	if($encoding=='base64'){
		$data=base64_decode($data);
	}
	file_put_contents($fileDir.'/'.$fileName,$data);
}
我来留个言

您的电子邮箱我一定会保密的哦!

昵称

邮箱

评论内容