Useful ToolsWebFetch
DocsWebFetch

WebFetch

Give your agents web scraping powers. Fetch, parse, and analyze web pages.

Quick Start

quickstart.py
from connectonion import Agent, WebFetch web = WebFetch() agent = Agent("researcher", tools=[web]) agent.input("What does stripe.com do?") agent.input("Get contact info from acme.com")

Usage

Option 1: Import directly

import_direct.py
from connectonion import WebFetch agent = Agent("researcher", tools=[WebFetch()])

Option 2: Copy and customize

Terminalbash
$co copy web_fetch
import_local.py
from tools.web_fetch import WebFetch # Your local copy

Installation

install.py
from connectonion import WebFetch web = WebFetch()

Low-Level Methods

Direct HTTP and parsing operations

fetch(url)

HTTP GET request, returns raw HTML

fetch.py
html = web.fetch("example.com") # Returns: "<!DOCTYPE html>..."

strip_tags(html)

Strip HTML tags, returns body text only

strip_tags.py
text = web.strip_tags(html) # Returns clean text without HTML

get_title(html)

Get page title

get_title.py
title = web.get_title(html) # Returns: "Example Domain"

get_links(html)

Extract all links from HTML

get_links.py
links = web.get_links(html) # Returns: [{'text': 'Home', 'href': '/'}, {'text': 'About', 'href': '/about'}]

get_emails(html)

Extract email addresses from HTML

get_emails.py
emails = web.get_emails(html) # Returns: ['support@example.com', 'sales@company.org']

get_social_links(html)

Extract social media links

get_social_links.py
html = web.fetch("openai.com") social = web.get_social_links(html) # Returns: {'twitter': 'https://x.com/OpenAI', 'youtube': '...', 'github': '...'}

High-Level Methods (LLM-Powered)

AI-powered analysis of web pages

analyze_page(url)

Use LLM to understand what a page/company does

analyze_page.py
result = web.analyze_page("stripe.com") # Returns: "Stripe is a technology company that builds economic infrastructure..."

get_contact_info(url)

Extract contact information using LLM

get_contact_info.py
result = web.get_contact_info("stripe.com/contact") # Returns: "Email: support@stripe.com, Phone: ..."

Composing Functions

Chain low-level methods together for custom workflows:

compose.py
# Get clean text from a URL text = web.strip_tags(web.fetch("example.com")) # Get title and text html = web.fetch("example.com") title = web.get_title(html) text = web.strip_tags(html)

Research Agent Example

research_agent.py
from connectonion import Agent, WebFetch, Memory web = WebFetch() memory = Memory() agent = Agent( name="researcher", tools=[web, memory], system_prompt="""You are a web researcher. You can: - Fetch and analyze websites - Extract contact information - Find social media profiles - Remember findings for later""" ) # Research a company agent.input("Research stripe.com and tell me what they do") # Find contact info agent.input("Get contact information from acme.com") # Build a lead list agent.input("Find all email addresses on techstartup.io and save them to memory") # Competitive analysis agent.input("Compare what stripe.com and square.com offer")

API Reference

MethodTypeDescription
fetch(url)Low-levelHTTP GET, returns raw HTML
strip_tags(html)Low-levelRemove HTML tags, return text
get_title(html)Low-levelExtract page title
get_links(html)Low-levelExtract all links
get_emails(html)Low-levelExtract email addresses
get_social_links(html)Low-levelExtract social media links
analyze_page(url)LLMAI analysis of what page/company does
get_contact_info(url)LLMAI extraction of contact info

Configuration

config.py
# Custom timeout (default: 15 seconds) web = WebFetch(timeout=30) # Use with agent agent = Agent("researcher", tools=[web])

Customizing

Need to modify WebFetch's behavior? Copy the source into your project and import from there:

Terminalbash
$co copy web_fetch
custom_import.py
# from connectonion import WebFetch # Before from tools.web_fetch import WebFetch # After — customize freely!

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.