lbonnet / crawler-toolkit
Shared, framework-agnostic building blocks for polite and safe web crawlers: SSRF-aware HTTP throttling, robots.txt parsing, and HTML link discovery.
v0.1.2
2026-09-04 14:26 UTC
Requires
- php: >=8.1
- ext-dom: *
- symfony/css-selector: ^6.4 || ^7.0 || ^8.0
- symfony/dom-crawler: ^6.4 || ^7.0 || ^8.0
- symfony/http-client: ^6.4 || ^7.0 || ^8.0
- symfony/http-foundation: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^10.5 || ^11.5
- symfony/phpunit-bridge: ^6.4 || ^7.0 || ^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-04 14:26:53 UTC
README
Shared, framework-agnostic building blocks for polite and safe web crawlers.
This is not a Symfony bundle: it's a plain library of standalone classes. Each consuming bundle wires them into its own service container itself.
Components
Http\ThrottledHttpClient—HttpClientInterfacedecorator enforcing a minimum delay between consecutive requests to the same host, with aThrottleExemptionInterfaceto temporarily exempt one host (typically the site currently being audited).Http\BoundedContentReader— reads an HTTP response body up to a byte cap, cancelling the request past that instead of buffering an unbounded (or malicious) response in memory.Http\EffectiveUrlResolver— resolves the URL a response was ultimately served from after any redirects the HTTP client already followed, so relative links in the body resolve against the right page.Robots\RobotsTxtChecker— fetches and parses a host'srobots.txt, exposingisAllowed(url)andcrawlDelay(url)for a configured user agent (Allow/Disallow/Crawl-delaydirectives, most-specific-rule-wins matching, wildcard and$end-anchors).Html\LinkDiscoverer— parses<a href>elements out of an HTML document into alist<DiscoveredHref>(absolute URL, anchor text, internal/external), handling relative URL resolution,<base href>, fragment stripping, ignored schemes (mailto:,tel:, ...), and exclusion regex patterns.Url\UrlNormalizer—normalizeForDedup()treatshttp://andhttps://variants of the same URL as the same page for visited-set tracking, without changing the URL actually requested.
Requirements
- PHP >= 8.1
- Symfony 6.4, 7.x, or 8.x
Installation
composer require lbonnet/crawler-toolkit
Security
To report a vulnerability, please don't open a public issue — see SECURITY.md for how to report it privately.
License
MIT — see LICENSE.