Skip to content

Instantly share code, notes, and snippets.

@wimvds
Last active December 15, 2015 11:38
Show Gist options
  • Save wimvds/5254464 to your computer and use it in GitHub Desktop.
Save wimvds/5254464 to your computer and use it in GitHub Desktop.
Fetch & dump all URLs from a Google XML sitemap
#!/usr/bin/env php
<?php
if ($argc !== 2) {
print "SYNTAX :\n";
print ' ' . $argv[0] . ' <url>';
print "\n";
return 0;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $argv[1]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
$xml = new SimpleXMLElement($data);
foreach ($xml->url as $urldata) {
print $urldata->loc . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment