Skip to content

Instantly share code, notes, and snippets.

@ozero
Created March 10, 2015 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozero/ad776df86a4c3effeac4 to your computer and use it in GitHub Desktop.
Save ozero/ad776df86a4c3effeac4 to your computer and use it in GitHub Desktop.
extract from damage report html
<?php
/*
Ingress: extract portal name, lat&long, address, agent name and date
from html files of Ingress damage report email which exported
from thunderbird addon 'Import/Export tools'.
*/
$files=glob("./*/*.*");
$regx_agent="\sby\s.*?<span.*?>(.*?)<";
$regx_date="Date:\s</div>(.*?)<";
$regx_portal='em;"><div>(.*?)</div><div><a.*?pll=(.*?)&z=.*?>(.*?)</a></div>';
$ext=array();
foreach($files as $k0=>$v0){
$content = join("",file($v0));
preg_match("#{$regx_agent}#",$content,$tmp_agent);
preg_match("#{$regx_date}#",$content,$tmp_date);
preg_match("#{$regx_portal}#",$content,$tmp_portal);
$ext[] = array(
'agent'=>$tmp_agent[1],
'date'=>$tmp_date[1],
'pname'=>$tmp_portal[1],
'pll'=>$tmp_portal[2],
'paddr'=>$tmp_portal[3],
);
}
print_r($ext);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment