forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
32 lines
957 B
PHP
32 lines
957 B
PHP
<?php
|
|
require_once(dirname(__FILE__) . "/../vendor/autoload.php");
|
|
|
|
use vipnytt\SitemapParser;
|
|
use vipnytt\SitemapParser\Exceptions\SitemapParserException;
|
|
|
|
/**
|
|
* Basic recursive example
|
|
* Fast and easy to use
|
|
* Optimized for smaller pages
|
|
*/
|
|
try {
|
|
$parser = new SitemapParser('MyCustomUserAgent');
|
|
$parser->parseRecursive('http://www.google.com/robots.txt');
|
|
echo '<h2>Sitemaps</h2>';
|
|
foreach ($parser->getSitemaps() as $url => $tags) {
|
|
echo 'URL: ' . $url . '<br>';
|
|
echo 'LastMod: ' . $tags['lastmod'] . '<br>';
|
|
echo '<hr>';
|
|
}
|
|
echo '<h2>URLs</h2>';
|
|
foreach ($parser->getURLs() as $url => $tags) {
|
|
echo 'URL: ' . $url . '<br>';
|
|
echo 'LastMod: ' . $tags['lastmod'] . '<br>';
|
|
echo 'ChangeFreq: ' . $tags['changefreq'] . '<br>';
|
|
echo 'Priority: ' . $tags['priority'] . '<br>';
|
|
echo '<hr>';
|
|
}
|
|
} catch (SitemapParserException $e) {
|
|
echo $e->getMessage();
|
|
}
|