dr4g0nsr/sitemap-crawler

使用robots.txt和sitemap.xml作为URL来源的任何类型网站的爬虫。用于缓存刷新非常有用。

1.0 2022-11-11 21:16 UTC

This package is auto-updated.

Last update: 2024-09-12 01:25:43 UTC


README

Test status

网站地图爬虫

使用网站地图爬取网站/刷新缓存。

文件不存储,只是触发URL。

使用Composer获取代码

composer require dr4g0nsr/sitemap-crawler

如何实现

创建config.php

<?php

$settings = [
    "sleep" => 0,
    "excluded" => []
];

使用如下代码

<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/config.php';

use dr4g0nsr\Crawler;

$url = 'https://candymapper.com';
print "Crawler version: " . Crawler::version() . PHP_EOL;

$crawler = new Crawler(['sleep' => 0, 'verbose' => true]);
$crawler->loadConfig(__DIR__ . '/config.php');
$sitemap = $crawler->getSitemap($url);
$crawler->crawlURLS($sitemap);

这是最简单的代码,您也可以在vendor/dr4g0nsr/SitemapCrawler/test目录下的test子目录中找到它。