Skip to main content
This example shows how to build a product extraction agent using Upsonic’s Agent with the built-in FirecrawlTools. Point it at any shopping website and it scrapes the page, pulls out product names, prices, and short descriptions, then returns the results as a clean, structured table. The example targets books.toscrape.com β€” a publicly available, scraping-safe demo bookstore β€” but the same pattern works for any publicly accessible e-commerce site.

Overview

The agent has three components:
  1. Agent β€” LLM-driven agent that orchestrates scraping and data extraction
  2. FirecrawlTools β€” Built-in Upsonic toolkit wrapping the Firecrawl API; only scrape_url is enabled to keep the tool surface minimal
  3. Task β€” Defines the target URL and the exact output format

Project Structure

Environment Variables

Get your free Firecrawl API key β€” Sign up at firecrawl.dev, navigate to your dashboard, and copy your key. No credit card required to get started.

Installation

Complete Implementation

main.py

requirements.txt

How It Works

StepWhat Happens
1agent.do(task) sends the task prompt to the LLM
2The LLM calls scrape_url("http://books.toscrape.com") via FirecrawlTools
3Firecrawl fetches the page and returns clean Markdown
4The LLM parses the Markdown, identifies every product block, and extracts name, price, and rating
5Results are formatted as a sorted Markdown table and returned

Sample Output

Extending the Example

Crawl multiple pages

Switch from scrape_url to crawl_website to follow pagination automatically:

Structured JSON extraction

Use extract_data for schema-driven, LLM-powered extraction directly inside Firecrawl:

Point at a different shop

Replace the URL in the task description with any publicly accessible store:

Key Features

FeatureDetail
Minimal tool surfaceOnly scrape_url is enabled β€” the agent cannot accidentally crawl, search, or batch-scrape
Clean Markdown inputFirecrawl strips boilerplate and returns structured Markdown, making product parsing straightforward
Model-agnosticSwap anthropic/claude-sonnet-4-6 for any Upsonic-supported provider
ExtensibleSwitch to crawl_website or extract_data for multi-page or schema-driven extraction

Security Notes

  • The agent only has access to scrape_url β€” it cannot read local files, execute code, or access other systems.
  • Only point the agent at publicly accessible URLs. Firecrawl respects robots.txt by default.
  • Store FIRECRAWL_API_KEY and ANTHROPIC_API_KEY in .env β€” never hardcode keys in source files.

Repository

View the full example: Firecrawl Shopping Scraper