katanavsgoutte
Katana is a next-generation web crawling and spidering framework written in Go by ProjectDiscovery. It is designed for fast, comprehensive endpoint and asset discovery and is widely used in the security research and bug bounty communities.
Katana offers multiple crawling modes:
- Standard mode Fast HTTP-based crawling without a browser. Parses HTML, JavaScript files, and other resources to discover endpoints and links.
- Headless mode Uses a headless Chrome browser for crawling JavaScript-rendered pages and single-page applications (SPAs).
- Passive mode Discovers URLs from external sources (Wayback Machine, CommonCrawl, etc.) without actively visiting the target.
Key features include:
- Scope control Configurable crawl scope with regex patterns for including/excluding URLs, domains, and file extensions.
- JavaScript parsing Extracts endpoints from JavaScript files, inline scripts, and AJAX requests even in standard (non-headless) mode.
- Customizable output Filter and format output with field selection, JSON output, and custom templates.
- Rate limiting Built-in rate limiting and concurrency control to avoid overwhelming targets.
- Proxy support HTTP and SOCKS5 proxy support with rotation.
- Form filling Can detect and auto-fill forms to discover endpoints behind form submissions.
While Katana was designed for security research and reconnaissance, its fast crawling capabilities and JavaScript parsing make it equally useful for web scraping discovery and sitemap generation.
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.
Highlights
Example Use
package main
import (
"context"
"math"
"github.com/projectdiscovery/katana/pkg/engine/standard"
"github.com/projectdiscovery/katana/pkg/output"
"github.com/projectdiscovery/katana/pkg/types"
)
func main() {
// Configure crawl options
options := &types.Options{
MaxDepth: 3,
FieldScope: "rdn", // restrict to root domain
BodyReadSize: math.MaxInt,
Timeout: 10,
Concurrency: 10,
Parallelism: 10,
Delay: 0,
RateLimit: 150,
Strategy: "depth-first",
OnResult: func(result output.Result) {
// Process each discovered URL
println(result.Request.URL)
},
}
// Create and run the crawler
crawlerOptions, _ := types.NewCrawlerOptions(options)
defer crawlerOptions.Close()
crawler, _ := standard.New(crawlerOptions)
defer crawler.Close()
// Start crawling
_ = crawler.Crawl("https://example.com")
}
<?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!"