【问题标题】:XML Sitemap generator in php [duplicate]php中的XML站点地图生成器[重复]
【发布时间】:2012-10-17 10:19:10
【问题描述】:

可能重复:
Creating an XML sitemap with PHP

我正在尝试构建一个应用程序,用户可以在其中输入他的网站 URL 并获取 XML 站点地图。我正在获取链接,用户通过在生成站点地图的网站目录中放置一个文件来获取其网站的 XML 站点地图。但我想为任何给定的 URL 生成它。我可以使用 php 获取任何给定网站的目录结构吗?任何帮助,将不胜感激。

【问题讨论】:

  • 我试图获取给定页面的 URL 列表,但它只给出该页面的 URL。我也想获得更改频率和优先级。如果我错了,请指导我。

标签: php url curl sitemap


【解决方案1】:

示例来自:http://www.alanmiller.com/blog/article/php-xml-sitemap-generator/

<?php

require_once('class.xml.sitemap.generator.php');

$entries[] = new xml_sitemap_entry('/', '1.0', 'weekly');
$entries[] = new xml_sitemap_entry('/foo.html', '0.9', 'weekly');
$entries[] = new xml_sitemap_entry('/bar.html', '0.1', 'monthly');
$entries[] = new xml_sitemap_entry('/baz.html', '0.1', 'monthly');

$conf = new xml_sitemap_generator_config;
$conf->setDomain('www.php.net');
$conf->setPath('/var/tmp/');
$conf->setFilename('sitemap.xml');
$conf->setEntries($entries);

$generator = new xml_sitemap_generator($conf);
$generator->write();

?>

【讨论】:

  • 嗨@twodayslate,感谢您的快速回复。但它没有给出预期的结果。请检查一次。
猜你喜欢
  • 1970-01-01
  • 2017-11-29
  • 2016-11-05
  • 1970-01-01
  • 2016-09-06
  • 1970-01-01
  • 2015-08-11
  • 1970-01-01
  • 2013-02-16
相关资源
最近更新 更多