[
// put any GuzzleHttp options here
]
];
try {
$parser = new SitemapParser('MyCustomUserAgent', $config);
$parser->addToQueue(['https://www.google.com/robots.txt']);
while (count($queue = $parser->getQueue()) > 0) {
// Loop through each sitemap individually
echo '
Parsing sitemap: ' . $queue[0] . '
';
$parser->parse($queue[0]);
foreach ($parser->getSitemaps() as $url => $tags) {
echo 'Sitemap
';
echo 'URL: ' . $url . '
';
echo 'LastMod: ' . $tags['lastmod'] . '
';
echo '
';
}
foreach ($parser->getURLs() as $url => $tags) {
echo 'URL: ' . $url . '
';
echo 'LastMod: ' . $tags['lastmod'] . '
';
echo 'ChangeFreq: ' . $tags['changefreq'] . '
';
echo 'Priority: ' . $tags['priority'] . '
';
echo '
';
}
}
} catch (SitemapParserException $e) {
echo $e->getMessage();
}