Skip to content

photonvscrawl4ai

GPL-3.0 61 3 12,807
1.4 thousand (month) Aug 24 2018 1.1.9(2018-10-21 03:39:17 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)

Photon is a Python library for web scraping. It is designed to be lightweight and fast, and can be used to extract data from websites and web pages. Photon can extract the following data while crawling:

  • URLs (in-scope & out-of-scope)
  • URLs with parameters (example.com/gallery.php?id=2)
  • Intel (emails, social media accounts, amazon buckets etc.)
  • Files (pdf, png, xml etc.)
  • Secret keys (auth/API keys & hashes)
  • JavaScript files & Endpoints present in them
  • Strings matching custom regex pattern
  • Subdomains & DNS related data

The extracted information is saved in an organized manner or can be exported as json.

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 photon import Photon #Create a new Photon instance ph = Photon() #Extract data from a specific element of the website url = "https://www.example.com" selector = "div.main" data = ph.get_data(url, selector) #Print the extracted data print(data) #Extract data from multiple websites asynchronously urls = ["https://www.example1.com", "https://www.example2.com"] data = ph.get_data_async(urls) ```
```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?