Skip to main content
This example shows how to build Upsonic LLM agents that can:
  1. Find the official website of a company using the Serper API
  2. Validate whether a given website belongs to that company

Overview

The Find Company Website example demonstrates how to use Upsonic agents with external APIs to perform intelligent web research. It consists of two main components:
  • Website Finder: Searches for and validates company websites
  • Website Validator: Verifies if a given URL belongs to a specific company
Both agents use the Serper API for web search and HTML parsing for validation, showcasing how Upsonic can integrate with external services for real-world applications.

Key Features

  • Intelligent Search: Uses Serper API to find company websites
  • Smart Validation: Analyzes website content to verify authenticity
  • Structured Output: Returns validated results with confidence scores
  • Error Handling: Graceful handling of API failures and invalid URLs
  • Domain Filtering: Excludes irrelevant domains (social media, directories)

Code Structure

Response Models

Serper API Client

HTML Utilities

Complete Implementation

find_company_website.py

serper_client.py

html_utils.py

validate_company_website.py

How It Works

1. Website Discovery Process

  1. Search: Uses Serper API to search for the company name
  2. Filter: Removes irrelevant domains (social media, directories)
  3. Validate: Analyzes each candidate website’s content
  4. Score: Assigns confidence scores based on brand matches
  5. Return: Returns the highest-scoring validated website

2. Validation Logic

The validation process checks for:
  • Brand in Domain: Highest score (0.9) when company brand appears in URL
  • Full Name Match: High score (0.8) when full company name appears in title/h1/footer
  • Brand Match: Medium score (0.6) when brand token appears in content
  • No Match: Score 0.0 when no relevant content is found

3. Content Analysis

The system analyzes:
  • Page Title: Company name in HTML title tag
  • H1 Headers: Main headings on the page
  • Footer Text: Company information in footer
  • Domain Name: Brand presence in URL structure

Usage

Setup

  1. Install dependencies:
  1. Copy .env.example to .env and add your Serper API key:
  1. Edit .env and replace the placeholder with your real key:
You can get a free API key at https://serper.dev.

Find a Company Website

Example output:

Validate a Company Website

Example output:

Use Cases

  • Business Research: Find official websites for companies
  • Due Diligence: Verify company website authenticity
  • Competitive Analysis: Identify competitor websites
  • Lead Generation: Validate business contact information
  • Brand Monitoring: Track official company web presence

File Structure

Notes

  • Finder: takes a company name, searches with Serper, validates candidates, and returns the best match
  • Validator: checks if a given URL belongs to a company
  • Both use Upsonic agents with external API integration
  • Domain Filtering: Automatically excludes social media and directory sites
  • Confidence Scoring: Provides reliability metrics for validation results

Repository

View the complete example: Find Company Website Example