webignition/website-sitemap-finder

查找给定网站的站点地图(.xml)

3.3 2019-04-03 14:21 UTC

This package is auto-updated.

Last update: 2024-08-29 04:08:55 UTC


README

概述

查找指定网站的站点地图URL。URL从robots.txt中提取。如果没有,则假定是sitemap.xml和sitemap.txt。

使用方法

"Hello World" 示例

<?php
use webignition\WebsiteSitemapFinder\Configuration;
use webignition\WebsiteSitemapFinder\WebsiteSitemapFinder;

$configuration = new Configuration([
    Configuration::KEY_ROOT_URL => 'http://google.com/',
]);

$finder = new WebsiteSitemapFinder($configuration);        
$sitemapUrls = $finder->findSitemapUrls();

$this->assertEquals($sitemapUrls, [
    'http://www.gstatic.com/culturalinstitute/sitemaps/www_google_com_culturalinstitute/sitemap-index.xml',
    'http://www.gstatic.com/s2/sitemaps/profiles-sitemap.xml',
    'https://www.google.com/sitemap.xml',
]);

构建

将作为库在项目中使用

如果作为另一个项目的依赖项使用,请更新该项目的composer.json文件并更新依赖项。

"require": {
    "webignition/website-sitemap-finder": "*"      
}

开发

该项目使用composer管理外部依赖。首先获取并安装它。

# Make a suitable project directory
mkdir ~/website-sitemap-finder && cd ~/website-sitemap-finder

# Clone repository
git clone git@github.com:webignition/website-sitemap-finder.git.

# Retrieve/update dependencies
composer.phar install

测试

查看travis上的项目以获取最新的构建状态,或者自己运行测试。

cd ~/website-sitemap-finder
composer.phar test