Abstract
Web scraping currently faces a trade-off between the efficiency of rule-based wrappers and the flexibility of Large Language Model (LLM) agents. We present AutoCrawler, a two-stage framework that leverages LLMs to automatically generate robust and reusable web scrapers. By combining a "progressive understanding" traversal strategy with a multi-page synthesis module, AutoCrawler bridges the gap between efficient but brittle rule-based wrappers and flexible but expensive LLM-based extraction agents.
1. Introduction: The Scraping Tug-of-War
Web scraping has traditionally been a tug-of-war between two paradigms. Wrapper-based methods are highly efficient rule-based functions (like XPaths) that work well until a website changes its layout, requiring manual repair. Conversely, language-agent-based methods use LLMs to "read" a page and extract data directly. While flexible, LLM agents are prohibitively expensive and slow for large-scale tasks because they must process every single page from scratch.
AutoCrawler addresses three core challenges: processing long, noisy HTML documents; ensuring scraper reusability across pages with structural variations; and establishing evaluation metrics that capture real-world executability.
2. Methodology
AutoCrawler treats scraper generation as an iterative "action sequence" task rather than a one-shot generation. It operates in two distinct phases.
2.1 Phase 1: Progressive Generation
Instead of feeding the entire HTML to an LLM, AutoCrawler uses a traversal strategy to prune irrelevant content. In the Top-down step, the agent starts at the root of the DOM tree and progressively refines its focus to the node containing the target data. If the agent realizes it has pruned too much, it performs a Step-back to find a more reliable anchor point. This significantly reduces the context window, helping the LLM focus on relevant structures.
2.2 Phase 2: Synthesis
To ensure the scraper is not overfitted to a single page, the system generates candidate scrapers from multiple "seed" pages. It then executes these candidates across the seeds and selects the one that performs most consistently.
3. Evaluation and Results
The framework was evaluated on three established benchmarks: SWDE (124,291 webpages), EXTENDED SWDE, and DS1.
3.1 Performance and Efficiency
AutoCrawler consistently outperformed baselines like Chain-of-Thought (CoT) and Reflexion across 8 different LLMs. Using GPT-4 Turbo, it achieved an F1 score of 88.69 on the SWDE dataset, outperforming specialized supervised models like WebFormer (86.58) and SimpDOM (83.06).
Crucially, AutoCrawler offers massive efficiency gains. Once a scraper is generated (taking a few minutes of LLM time), it can be executed by a standard parser at near-zero cost. The authors found that AutoCrawler becomes more efficient than direct LLM extraction after only ~20 pages. Given that many sites have thousands of pages, the cost savings are astronomical.
3.2 Key Insights
The "progressive understanding" approach reveals that LLMs are better at writing XPaths when they don't see the whole page. By iteratively narrowing down the HTML, the model avoids getting lost in the "noise" of headers, footers, and sidebars. Furthermore, the Synthesis stage acts as a filter for robustness, ensuring the generated XPath relies on stable, site-wide attributes (like @class) rather than page-specific text.
4. Conclusion
AutoCrawler demonstrates that LLMs are most effective when used as architects of scraping logic rather than manual data extractors. While currently focused on "vertical" web pages with structured data (like product listings), the framework provides a scalable path forward for automated web data extraction. Future work will focus on handling complex navigation and multi-valued attributes.
Summary updated