http(s) URL to remember(), control what gets extracted with CSS-selector rules, and visualize the result.
Before you start:
- Complete Quickstart to understand basic operations
- Install the scraping extra:
pip install cognee[scraping](BeautifulSoup, Tavily, Playwright). Keenable needs no extra dependencies.
Code in Action
Step 1: Define Extraction Rules
Extraction rules tell the BeautifulSoup loader which parts of the page to keep. Each rule maps a name to a CSS selector (or XPath):
Rules are optional — without them the loader applies a comprehensive default set covering common HTML content areas (headings, paragraphs, articles, tables, code blocks, etc.). See Loaders for more
preferred_loaders examples.
Step 2: Remember the URL
remember() recognizes the URL, fetches the page, extracts content according to your rules, and builds the knowledge graph in one call.
Step 3: Visualize the Result
Choosing a crawler
Cognee can fetch pages with one of three backends:- Built-in BeautifulSoup crawler (default) — asynchronous HTTP requests, robots.txt compliance, rate limiting, and Playwright rendering for JavaScript-heavy pages.
- Tavily — richer extraction from complex pages. Requires
TAVILY_API_KEY. - Keenable — clean markdown extraction via the Keenable API. Requires
KEENABLE_API_KEY.
remember() or add(), the backend is picked from the environment in this order:
- Tavily, if
TAVILY_API_KEYis set - Keenable, if
KEENABLE_API_KEYis set - The built-in crawler
TAVILY_API_KEY to route through Keenable.
See Python API: add() for the crawler configuration options (tavily_config, soup_crawler_config).
Full Example
The script is available on our github. The complete flow — forget, remember a URL with extraction rules, and visualize — is in the following example:Web URL content ingestion
Web URL content ingestion
Loaders
How Cognee turns files and pages into ingestable content
Graph Visualization
Render your knowledge graph to an interactive HTML file