Skip to content

gouttevscrawlee

MIT 137 2 9,164
8.5 thousand (month) Dec 02 2012 v4.0.3(2023-04-01 09:05:33 ago)
26,606 30 131 Apache-2.0
Apr 22 2022 791.9 thousand (month) 3.18.2(2026-11-27 20:11:10 ago)

Goutte is a screen scraping and web crawling library for PHP built on top of Symfony components (HttpClient, DomCrawler, BrowserKit). It provides a simple, elegant API for navigating websites, submitting forms, and extracting data.

Note: Goutte is deprecated as of 2023. Its functionality has been merged into Symfony's HttpBrowser component. For new projects, use Symfony HttpClient with DomCrawler directly. Goutte is still included here because it remains widely used in existing codebases and many tutorials reference it.

Key features include:

  • Simple scraping API Combines HTTP client and DOM crawler into a single interface. Navigate pages, click links, and extract content with a clean, chainable API.
  • CSS selector support Uses Symfony DomCrawler's filter() and each() methods with CSS selectors for extracting data from HTML.
  • Form handling Can find, fill in, and submit HTML forms. Handles all standard input types including file uploads.
  • Cookie management Automatically manages cookies across requests within a session.
  • Guzzle integration Uses Guzzle HTTP client under the hood for reliable HTTP communication with proxy support, authentication, and custom headers.
  • Link crawling Can follow links by text or CSS selector, making multi-page scraping straightforward.

For new PHP scraping projects, consider using Symfony HttpClient + DomCrawler directly, or the Roach framework for a more feature-complete solution.

Crawlee is a modern web scraping and browser automation framework for JavaScript and TypeScript, built by Apify. It is the successor to the Apify SDK and provides a unified interface for building reliable web scrapers and crawlers that can scale from simple scripts to large-scale data extraction projects.

Crawlee supports multiple crawling strategies through different crawler classes:

  • CheerioCrawler For fast, lightweight HTML scraping using Cheerio (no browser needed). Best for static pages.
  • PlaywrightCrawler Uses Playwright for full browser automation. Handles JavaScript-rendered pages, SPAs, and complex interactions.
  • PuppeteerCrawler Similar to PlaywrightCrawler but uses Puppeteer as the browser automation backend.
  • HttpCrawler Minimal crawler for raw HTTP requests without HTML parsing.

Key features include:

  • Automatic request queue management with configurable concurrency and rate limiting
  • Built-in proxy rotation with session management
  • Persistent request queue and dataset storage (local or cloud via Apify)
  • Automatic retry and error handling with configurable strategies
  • TypeScript-first design with full type safety
  • Middleware-like request/response hooks (preNavigationHooks, postNavigationHooks)
  • Output pipelines for storing extracted data
  • Easy deployment to Apify cloud platform

Crawlee is considered the most feature-complete web scraping framework in the JavaScript/TypeScript ecosystem, comparable to Python's Scrapy but with native browser automation support.

Highlights


popularcss-selectors
populartypescriptextendiblemiddlewaresoutput-pipelineslarge-scaleproxy

Example Use


<?php
require 'vendor/autoload.php';

use Goutte\Client;

$client = new Client();

// Navigate to a page
$crawler = $client->request('GET', 'https://example.com');
echo $crawler->filter('title')->text();

// Extract data using CSS selectors
$crawler->filter('.product')->each(function ($node) {
    $name = $node->filter('.name')->text();
    $price = $node->filter('.price')->text();
    echo "$name: $price\n";
});

// Click a link
$link = $crawler->selectLink('Next Page')->link();
$crawler = $client->click($link);

// Fill in and submit a form
$crawler = $client->request('GET', 'https://example.com/login');
$form = $crawler->selectButton('Login')->form([
    'username' => 'user@example.com',
    'password' => 'password123',
]);
$crawler = $client->submit($form);

// Cookies are maintained automatically across requests
echo $crawler->filter('h1')->text(); // "Welcome back!"
import { PlaywrightCrawler, Dataset } from 'crawlee';

// Create a crawler with Playwright for JS rendering
const crawler = new PlaywrightCrawler({
    // Limit concurrency to avoid overwhelming the target
    maxConcurrency: 5,

    // This function is called for each URL
    async requestHandler({ request, page, enqueueLinks }) {
        const title = await page.title();

        // Extract data from the page
        const products = await page.$$eval('.product', (els) =>
            els.map((el) => ({
                name: el.querySelector('.name')?.textContent,
                price: el.querySelector('.price')?.textContent,
            }))
        );

        // Store extracted data
        await Dataset.pushData({
            url: request.url,
            title,
            products,
        });

        // Follow links to crawl more pages
        await enqueueLinks({
            globs: ['https://example.com/products/**'],
        });
    },
});

// Start crawling
await crawler.run(['https://example.com/products']);

Alternatives / Similar


Was this page helpful?