Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions examples/agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_openai import ChatOpenAI

from langchain_scrapegraph.tools import (
GetCreditsTool,
SearchScraperTool,
SmartScraperTool,
)
from langchain_scrapegraph.tools import ExtractTool, GetCreditsTool, SearchTool

load_dotenv()

# Initialize the tools
tools = [
SmartScraperTool(),
ExtractTool(),
GetCreditsTool(),
SearchScraperTool(),
SearchTool(),
]

# Create the prompt template
Expand Down
103 changes: 0 additions & 103 deletions examples/agentic_scraper_tool.py

This file was deleted.

156 changes: 0 additions & 156 deletions examples/agentic_scraper_tool_schema.py

This file was deleted.

30 changes: 30 additions & 0 deletions examples/crawl_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Crawl Tool Example - LangChain Tool (v2 API)

Replaces the old SmartCrawler tool. Uses namespaced crawl operations.
"""

import time

from langchain_scrapegraph.tools import CrawlStartTool, CrawlStatusTool

# Initialize tools
start_tool = CrawlStartTool()
status_tool = CrawlStatusTool()

# Start a crawl job
result = start_tool.invoke(
{
"url": "https://example.com",
"depth": 2,
"max_pages": 5,
"format": "markdown",
}
)
print("Crawl started:", result)

# Check status
crawl_id = result.get("id")
if crawl_id:
time.sleep(5)
status = status_tool.invoke({"crawl_id": crawl_id})
print("Crawl status:", status)
18 changes: 18 additions & 0 deletions examples/extract_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Extract Tool Example - LangChain Tool (v2 API)

Replaces the old SmartScraper tool. Extracts structured data from webpages using AI.
"""

from langchain_scrapegraph.tools import ExtractTool

# Initialize the tool
tool = ExtractTool()

# Basic extraction
result = tool.invoke(
{
"url": "https://example.com",
"prompt": "Extract the main heading and first paragraph",
}
)
print(result)
22 changes: 22 additions & 0 deletions examples/extract_tool_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Extract Tool with Schema Example - LangChain Tool (v2 API)"""

from pydantic import BaseModel, Field

from langchain_scrapegraph.tools import ExtractTool


class WebsiteInfo(BaseModel):
title: str = Field(description="The main title of the page")
description: str = Field(description="The main description")


# Initialize with output schema
tool = ExtractTool(llm_output_schema=WebsiteInfo)

result = tool.invoke(
{
"url": "https://example.com",
"prompt": "Extract the title and description",
}
)
print(result)
25 changes: 25 additions & 0 deletions examples/monitor_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Monitor Tool Example - LangChain Tool (v2 API)

Replaces the old Scheduled Jobs tools. Uses the monitor namespace.
"""

from langchain_scrapegraph.tools import MonitorCreateTool, MonitorListTool

# Initialize tools
create_tool = MonitorCreateTool()
list_tool = MonitorListTool()

# Create a monitor
result = create_tool.invoke(
{
"name": "Price Monitor",
"url": "https://example.com/products",
"prompt": "Extract current product prices",
"cron": "0 9 * * *", # Daily at 9 AM
}
)
print("Monitor created:", result)

# List all monitors
monitors = list_tool.invoke({})
print("All monitors:", monitors)
Loading