Skip to main content
Scrape web pages and feed the extracted content into cognee using ScrapeGraphAI. The cognee-community-tasks-scrapegraph package provides two async tasks: scrape_urls for extraction and scrape_and_add for end-to-end scrape-to-graph ingestion.

Why Use This Integration

  • Prompt-Based Extraction: Describe what you want in natural language — no CSS selectors or scraper maintenance
  • Single Function Pipeline: scrape_and_add scrapes, ingests, and builds the graph in one call
  • Structured Output: Optionally pass a Pydantic schema for domain-specific extraction
  • Source Attribution: Each scraped page is tagged with its origin URL in the knowledge graph
  • JavaScript Rendering: Handles JS-rendered pages and common bot protection

Installation

Or with uv:

Requirements

You need two API keys:
See LLM Providers and Embedding Providers if you want to use a provider other than OpenAI.

Quick Start

1. Scrape and Inspect

Use scrape_urls to verify what ScrapeGraphAI extracts before building a graph:
The user_prompt tells ScrapeGraphAI what to focus on when extracting content from each page.

2. Build the Knowledge Graph

Use scrape_and_add to scrape, ingest, and build the graph in one call:
The prune calls reset the local database. Skip them when building incrementally on top of an existing graph.

Structured Extraction

When you know the shape of the data you need, pass a Pydantic schema to ScrapeGraphAI’s smartscraper directly. This bypasses the integration’s scrape_urls and gives you full control over the output structure:

Querying the Graph

Once the graph is built, use cognee.recall(...) to query it.

Use Cases

Scrape competitor product and pricing pages, build a knowledge graph, then query across all of them:
  1. Gather competitor URLs (product pages, pricing, docs)
  2. Use scrape_and_add with a prompt focused on pricing, features, and positioning
  3. Query with synthesis questions like “Which product is best for enterprise use cases?”
Scope queries to the dataset with datasets=["competitive_intel"].
Scrape news sources on a schedule and add to the existing graph incrementally:
  1. Set up a list of news/blog URLs
  2. Run scrape_and_add daily (skip the prune calls to accumulate data)
  3. Query across the full timeline: “What are the biggest trends this week?”
The graph gets better over time as entities and relationships accumulate.
Collect and correlate information from many sources:
  1. Scrape documentation, blog posts, and GitHub READMEs for a topic
  2. Build the graph with scrape_and_add
  3. Ask cross-source questions: “How does library X compare to library Y?”
Use structured extraction with Pydantic schemas for consistent input.
Map out an entire product category:
  1. Scrape product pages with a schema targeting name, features, pricing, and audience
  2. Ingest into cognee
  3. Query for patterns: “Which products target developers?” or “What pricing models are most common?”

GitHub Repository

View source code and examples

Blog Post

Read full tutorial on ScrapeGraph website