我有一个网站,其中包含100个HTML文件的目录。 我希望抓取工具抓取所有html文件的目录。 我已经添加了下面这句话对我的robots.txt:是否允许在sitemap.xml文件中使用通配符?
Allow /DirName/*.html$
有没有什么办法,包括在sitemap.xml的文件目录中的文件,以便在目录中的所有HTML文件将抓取的? 像这样:
<url>
<loc>MyWebsiteName/DirName/*.html</loc>
</url>
我有一个网站,其中包含100个HTML文件的目录。 我希望抓取工具抓取所有html文件的目录。 我已经添加了下面这句话对我的robots.txt:是否允许在sitemap.xml文件中使用通配符?
Allow /DirName/*.html$
有没有什么办法,包括在sitemap.xml的文件目录中的文件,以便在目录中的所有HTML文件将抓取的? 像这样:
<url>
<loc>MyWebsiteName/DirName/*.html</loc>
</url>
的sitemap protocol既不限制或允许使用通配符;说实话这是我第一次听到这个。另外,我非常确定搜索引擎不能在站点地图中使用通配符。
请查看Google的推荐sitemap generators。有很多工具可以让你瞬间创建站点地图。
它不允许使用通配符。如果您在服务器上运行php,则可以列出目录中的所有文件,并使用DirectoryIterator自动生成sitemap.xml。
// this is assume you have already a sitemap class.
$sitemap = new Sitemap;
// iterate the directory
foreach(new DirectoryIterator('/MyWebsiteName/DirName') as $directoryItem)
{
// Filter the item
if(!$directoryItem->isFile()) continue;
// New basic sitemap.
$url = new Sitemap_URL;
// Set arguments.
$url->set_loc(sprintf('/DirName/%1$s', $directoryItem->getBasename()))
->set_last_mod(1276800492)
->set_change_frequency('daily')
->set_priority(1);
// Add it to sitemap.
$sitemap->add($url);
}
// Render the output.
$response = $sitemap->render();
// Cache the output for 24 hours.
$cache->set('sitemap', $response, 86400);
// Output the sitemap.
echo $response;