Skip to main content
This example demonstrates how to build Upsonic LLM agents that autonomously explore ecommerce websites and extract structured product data β€” powered by the Serper API for web scraping and LLM-driven reasoning for intelligent navigation.

Overview

In this task, the agent:
  1. Finds the official website of a company using the find_company_website agent
  2. Explores the site intelligently using a website_scraping tool (Serper API)
  3. Extracts structured product information β€” including name, price, brand, availability, and URL β€” from one of the product pages
Unlike traditional scrapers, this agent uses LLM reasoning to decide which pages to explore, how to navigate the site, and when to retry.

Key Features

  • Autonomous Exploration: LLM handles all website navigation and product discovery
  • Intelligent Navigation: Dynamically explores product pages without hardcoded paths
  • Structured Extraction: Returns validated product data in Pydantic models
  • Serper Integration: Uses Serper API for reliable web scraping
  • Error Handling: Graceful handling of failed requests and invalid pages

Code Structure

Response Model

Website Scraping Tool

Complete Implementation

How It Works

1. Website Discovery

  • Uses find_company_website to locate and validate the company’s official homepage
  • Ensures the website is legitimate and belongs to the specified company

2. Intelligent Exploration

  • The LLM agent uses the website_scraping tool (Serper API) to fetch page content
  • It identifies product-related sublinks such as /shop, /products, /collections, etc.
  • It navigates autonomously through relevant subpages until it finds a valid product

3. Product Extraction

Once a product page is found, the LLM extracts:
  • product_name: The name of the product
  • product_price: Current price (if available)
  • product_brand: Brand name
  • availability: Stock status
  • url: Direct link to the product page
The extracted data is returned in a validated ProductInfo Pydantic model.

Usage

Setup

  1. Install dependencies:
  1. Configure your Serper API key:
Copy .env.example to .env:
Then edit .env and add your API key:
You can get a free key from https://serper.dev.

Run the Agent

Run the agent for any company name:
Example output:
Try it with other companies:

Advanced Usage

Custom Product Extraction

Batch Company Processing

Enhanced Product Information

Use Cases

  • Competitive Analysis: Extract product information from competitor websites
  • Price Monitoring: Track product prices across different companies
  • Product Research: Gather product data for market analysis
  • E-commerce Intelligence: Understand product offerings and pricing strategies
  • Market Research: Analyze product categories and availability

File Structure

Notes

  • No custom scraping β€” all content retrieval uses Serper’s API
  • No path or subdomain restrictions β€” the LLM determines navigation dynamically
  • Unified Task design: website discovery β†’ exploration β†’ extraction handled within one Task object
  • Type-safe output using the Pydantic ProductInfo model
  • Requires the find_company_website example for website lookup

Dependencies

This example depends on:
  • Serper API: For web scraping functionality
  • Find Company Website: For website discovery and validation
  • Upsonic Framework: For LLM agent orchestration

Repository

View the complete example: Find Example Product Example