Search by

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.

Maintainers

Package info

github.com/lbonnet-gda/crawler-toolkit

pkg:composer/lbonnet/crawler-toolkit

Transparency log

Statistics

Installs: 180

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.2 2026-09-04 14:26 UTC

This package is auto-updated.

Last update: 2026-09-04 14:26:53 UTC


README

CI Latest Version PHP Version License

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\ThrottledHttpClientHttpClientInterface decorator enforcing a minimum delay between consecutive requests to the same host, with a ThrottleExemptionInterface to 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's robots.txt, exposing isAllowed(url) and crawlDelay(url) for a configured user agent (Allow/Disallow/Crawl-delay directives, most-specific-rule-wins matching, wildcard and $ end-anchors).
  • Html\LinkDiscoverer — parses <a href> elements out of an HTML document into a list<DiscoveredHref>(absolute URL, anchor text, internal/external), handling relative URL resolution, <base href>, fragment stripping, ignored schemes (mailto:, tel:, ...), and exclusion regex patterns.
  • Url\UrlNormalizernormalizeForDedup() treats http:// and https:// 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.