1. Go to this page and download the library: Download changhorizon/crawler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
changhorizon / crawler example snippets
use ChangHorizon\Crawler\Crawler;
use ChangHorizon\Crawler\Http\CurlHttpClient;
use ChangHorizon\Crawler\Storage\PdoDocumentStorage;
use Psr\Log\NullLogger;
$startUrl = 'https://example.com';
$httpClient = new CurlHttpClient();
$storage = new PdoDocumentStorage($pdoConnection); // $pdoConnection 为已初始化的 PDO 实例
$logger = new NullLogger(); // 可替换为任何 PSR-3 实现,如 Monolog
$crawler = new Crawler($startUrl, $httpClient, $storage, $logger);
$crawler->run();