From 5f71eeb6a5d78f962a36faebf1c14894f6d4983a Mon Sep 17 00:00:00 2001 From: James Date: Wed, 6 Jan 2021 17:21:04 +0000 Subject: [PATCH] improve docker output --- docker/crawl.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/docker/crawl.php b/docker/crawl.php index 6344614..d1248c8 100644 --- a/docker/crawl.php +++ b/docker/crawl.php @@ -7,12 +7,35 @@ if(!$url=getenv('CRAWL_URL')){ die("No env: CRAWL_URL\n"); } +if($code=getenv('CRAWL_CODE')){ + $codes=array_filter(array_map('trim',explode(',',$code))); +}else{ + $codes=[]; +} + $crawler=new Crawler(); $crawler->crawl($url); +$summary=[]; +$details=''; foreach($crawler->getResults() as $url=>$result){ - echo("{$result['code']} {$url}\n"); + $summary[$result['code']]++; + + if( count($codes)==0 || in_array($result['code'],$codes) ){ + $details.="{$result['code']} {$url}\n"; foreach($result['foundOn'] as $url=>$count){ - echo(" <- ($count) $url\n"); + $details.=" <- ($count) $url\n"; } + } +} + +ksort($summary); +echo '|code|count|'."\n"; +echo '|----|-----|'."\n"; +foreach($summary as $code=>$count){ + echo "| $code | $count |\n"; +} + +if($details){ + echo "\n\n----\n\n```\n$details\n```\n"; }