bitandblack/sitemap
Composer 安装命令:
composer require bitandblack/sitemap
包简介
Creates a sitemap.xml by parsing the whole website.
README 文档
README
Bit&Black Sitemap
Creates a sitemap.xml by parsing the whole website including all language versions and all images.
If multiple language versions are found, multiple xml files will be written.
Installation
This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/sitemap.
Usage
Auto-generation of a sitemap for a whole website
Set up the sitemap generation like that:
<?php
use BitAndBlack\Sitemap\Config\YamlConfig;
use BitAndBlack\Sitemap\SitemapCrawler;
use BitAndBlack\Sitemap\Writer\FileWriter;
$config = new YamlConfig('/path/to/config.yaml');
$writer = new FileWriter('/path/to/xml/files');
$sitemapCrawler = new SitemapCrawler(
$config,
$writer
);
$sitemapCrawler->createSitemap('https://crawl.me');
The YamlConfig stores some information which are needed when the process needs to run in multiple steps. Therefore it needs a path where the config file may get stored.
FileWriter stores the xml files, so it needs to know a folder for those files.
createSitemap() starts the crawling. If the time limit has been reached, the process will stop and store its status in the config file. If you call createSitemap() again it will continue the process. This is helpful for large websites which may take a long time to crawl.
Options
Page limit
Set a page limit that stops the crawler when the defined page count has been reached:
<?php
$sitemapCrawler->setCrawlingLimit(500);
Crawling a single page
You can crawl a single page by using the PageCrawler class. It will result in an object containing the page's headers, the body and some information about the languages, links and media.
<?php
use BitAndBlack\Sitemap\PageCrawler;
$pageCrawler = new PageCrawler('https://www.bitandblack.com/de.html');
$page = $pageCrawler->getPage();
Manual generation of the sitemap.xml
You can also create the sitemap.xml by your own:
<?php
use BitAndBlack\Sitemap\Collection;
use BitAndBlack\Sitemap\Config\YamlConfig;
use BitAndBlack\Sitemap\Page;
use BitAndBlack\Sitemap\SitemapXML;
$collection = new Collection(
new YamlConfig()
);
/**
* The page doesn't need to exist.
*/
$page = new Page('https://example.org');
$sitemapXML = new SitemapXML($collection, [$page]);
file_put_contents(
'sitemap.xml',
$sitemapXML->getSitemap()->saveXML()
);
Available Crawlers
Per default, the Bit&Black Sitemap library uses the Symfony Http Client for requests.
You can use a different crawler, depending on your needs. Currently supported are:
The AutoPageCrawler will detect the available crawler by its own.
However, you can set up the PageCrawler with a specific crawler, for example:
<?php
use BitAndBlack\Sitemap\PageCrawler;
use BitAndBlack\Sitemap\PageCrawler\ReactCrawler;
$pageCrawler = new PageCrawler();
$pageCrawler->setPageCrawler(new ReactCrawler());
Help
If you have any questions, feel free to contact us under hello@bitandblack.com.
Further information about Bit&Black can be found under www.bitandblack.com.
bitandblack/sitemap 适用场景与选型建议
bitandblack/sitemap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.88k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Sitemap」 「crawler」 「BitAndBlack」 「WirbelWild」 「Köngeter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bitandblack/sitemap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bitandblack/sitemap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bitandblack/sitemap 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight, dependency free PHP class that acts as wrapper for Crawlbase API
Symfony sitemap generator
PHP Simple Sitemap Generator
Strong link obfuscation with PHP and JavaScript. Object-oriented, using the Rot47 algorithm. Hides https, email, phone and sms links from being crawled by spambots.
Interfaces for web resource models and services to retrieve and create them
统计信息
- 总下载量: 4.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-21