Skip to content

dudevscrawl4ai

AGPL-3.0 32 2 425
54 (month) Feb 20 2022 0.1.3(2023-08-01 20:28:33 ago)
63,373 5 54 Apache-2.0
May 01 2024 1.5 million (month) 0.8.6(2026-03-24 15:07:50 ago)

Dude (dude uncomplicated data extraction) is a very simple framework for writing web scrapers using Python decorators. The design, inspired by Flask, was to easily build a web scraper in just a few lines of code. Dude has an easy-to-learn syntax.

The simplest web scraper will look like this: ```python from dude import select

@select(css="a") def get_link(element): return {"url": element.get_attribute("href")} ```

dude supports multiple parser backends: - playwright
- lxml
- parsel - beautifulsoup - pyppeteer - selenium

Crawl4AI is an open-source AI-powered web crawling and data extraction library for Python. It uses large language models (LLMs) to intelligently extract structured data from web pages with minimal code. Unlike traditional scraping frameworks that rely on CSS selectors or XPath, Crawl4AI can understand page content semantically and extract data based on natural language descriptions of what you want.

Key features include:

  • LLM-based extraction Define what data you want in plain English and Crawl4AI uses LLMs to find and extract it from the page content. Supports multiple LLM providers including OpenAI, Anthropic, and local models.
  • Automatic crawling Built-in crawler with support for JavaScript rendering, parallel crawling, and session management.
  • Structured output Returns data in structured formats (JSON, Pydantic models) making it easy to integrate into data pipelines.
  • Markdown conversion Can convert web pages to clean markdown format, useful for feeding content to LLMs.
  • Chunking strategies Multiple strategies for breaking down large pages into processable chunks for LLM extraction.
  • Async support Built on async Python for efficient concurrent crawling and extraction.

Crawl4AI is particularly useful for scraping unstructured content where writing traditional CSS/XPath selectors would be tedious or fragile. It excels at content extraction, article parsing, and data mining from diverse page layouts.

Highlights


ai-poweredasyncpopular

Example Use


```python from dude import select """ This example demonstrates how to use Parsel + async HTTPX To access an attribute, use: selector.attrib["href"] You can also access an attribute using the ::attr(name) pseudo-element, for example "a::attr(href)", then: selector.get() To get the text, use ::text pseudo-element, then: selector.get() """ @select(css="a.url", priority=2) async def result_url(selector): return {"url": selector.attrib["href"]} # Option to get url using ::attr(name) pseudo-element @select(css="a.url::attr(href)", priority=2) async def result_url2(selector): return {"url2": selector.get()} @select(css=".title::text", priority=1) async def result_title(selector): return {"title": selector.get()} @select(css=".description::text", priority=0) async def result_description(selector): return {"description": selector.get()} if __name__ == "__main__": import dude dude.run(urls=["https://dude.ron.sh"], parser="parsel") ```
```python from crawl4ai import AsyncWebCrawler, CrawlerRunConfig from crawl4ai.extraction_strategy import LLMExtractionStrategy import asyncio async def main(): # Basic crawling - get page as markdown async with AsyncWebCrawler() as crawler: result = await crawler.arun(url="https://example.com") print(result.markdown) # clean markdown content # AI-powered extraction with structured output strategy = LLMExtractionStrategy( instruction="Extract all product names and prices from this page", ) config = CrawlerRunConfig(extraction_strategy=strategy) async with AsyncWebCrawler() as crawler: result = await crawler.arun( url="https://example.com/products", config=config, ) print(result.extracted_content) # structured JSON output asyncio.run(main()) ```

Alternatives / Similar


Was this page helpful?