Skip to content

Instantly share code, notes, and snippets.

@staabm
Created June 10, 2016 10:14
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 staabm/b06a39d524a9e5aabf46ebce74304a3a to your computer and use it in GitHub Desktop.
Save staabm/b06a39d524a9e5aabf46ebce74304a3a to your computer and use it in GitHub Desktop.
melody script crawler
<?php
<<<CONFIG
packages:
- "codeguy/arachnid: 1.*"
CONFIG;
set_time_limit(0);
$crawler = new \Arachnid\Crawler('https://www.example.com/', 5);
$crawler->traverse();
$links = $crawler->getLinks();
echo "<style>
.http-200 {
color: green;
}
.http-301,.http-302 {
color: yellow;
}
.http-404, .http-500 {
color: red;
}
</style>";
echo "<table>";
foreach($links as $link) {
echo "<tr>";
echo "<td>". $link['absolute_url'] ."</td>";
echo "<td class='http-". $link['status_code'] ."'>". $link['status_code'] ."</td>";
echo "</tr>";
}
echo "</table>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment