Skip to main content
Welcome to the ScrapeGraphAI examples collection. These hands-on examples demonstrate real-world use cases and help you get started quickly with the library.

What You’ll Learn

Through these examples, you’ll discover how to:
  • Extract data from websites using natural language prompts
  • Scrape multiple pages simultaneously
  • Process local documents (CSV, PDF, text)
  • Integrate web search capabilities
  • Define custom schemas for structured output
  • Handle various data formats and sources

Available Examples

Basic Scraping

Get started with simple web scraping using SmartScraperGraph

Multi-Page Scraping

Learn to scrape multiple URLs in a single operation

Local Documents

Extract data from CSV files and text documents

Search Integration

Combine web search with intelligent scraping

Custom Schemas

Define Pydantic schemas for structured, validated output

Example Categories

Web Scraping

Extract data from websites using AI-powered natural language queries. Perfect for news sites, e-commerce, social media, and more.

Document Processing

Process local files including CSV, JSON, XML, and PDF documents. Extract structured information from unstructured text.

Search & Discovery

Combine search engines with scraping to find and extract information across the web automatically.

Advanced Patterns

Learn advanced techniques like custom schemas, multi-source scraping, and data validation.

Prerequisites

Before running these examples, make sure you have:
  1. Installed ScrapeGraphAI
    pip install scrapegraphai
    
  2. Set up API keys Create a .env file with your API credentials:
    OPENAI_API_KEY=your_key_here
    
  3. Installed dependencies
    pip install python-dotenv playwright
    playwright install
    

Code Structure

All examples follow a consistent pattern:
1

Import dependencies

Load required modules and environment variables
2

Configure the graph

Define LLM settings and scraping parameters
3

Create graph instance

Initialize the appropriate graph type with your prompt and source
4

Run and process

Execute the graph and handle the results

Running the Examples

Each example is self-contained and can be run directly:
python example_name.py
Make sure your API keys are properly configured in your .env file before running any examples.

Need Help?

If you encounter issues:

Next Steps

Start with Basic Scraping to learn the fundamentals, then explore more advanced examples as you build confidence with the library.