LangChain

Web Data

21 LangChain tools that let an agent read web pages through the Geonode Scraper API: extract a page as Markdown or HTML, run batches and crawls, map a site's URLs, search the web and check usage. Package: geonode-scraper-langchain on PyPI.

Before you start

  • Python 3.10 or newer.
  • A Geonode API key. Sign in to the Geonode dashboard, open API Keys, and create a key or copy an existing one.
  • A chat model for your agent, from any provider LangChain supports.

Install

pip install geonode-scraper-langchain

This installs langchain-core and the shared geonode-scraper-tools-core. For the agent example below, also install langchain and your model provider's package, for example pip install langchain langchain-anthropic.

Configure

import os

from geonode_scraper_langchain import build_langchain_tools
from geonode_scraper_tools_core import ScraperToolSettings

settings = ScraperToolSettings(
    host="https://scraper.geonode.io",
    api_key=os.environ["GEONODE_SCRAPER_API_KEY"],
)
tools = build_langchain_tools(settings=settings)

host and api_key are required. The other settings have defaults:

SettingDefaultWhat it does
request_timeoutnoneSeconds to wait for each HTTP response.
max_retries0Extra attempts after a failed request.
retry_backoff_seconds1.0Pause before the first retry.
poll_interval_seconds3.0How often the wait_for_* tools check a job.
poll_timeout_seconds60.0How long the wait_for_* tools wait before giving up.
verify_sslTrueCheck TLS certificates.

Use the tools in an agent

from langchain.agents import create_agent

agent = create_agent("anthropic:claude-sonnet-5-5", tools=tools)
result = agent.invoke(
    {"messages": [{"role": "user", "content": "What does https://example.com say? Answer in one sentence."}]}
)
print(result["messages"][-1].content)

Any LangChain chat model works in place of the model name. The agent picks the tools itself: here it calls scraper_extract_content and reads the Markdown.

Call a tool directly

Every tool is a regular LangChain tool, so you can call it without an agent, for example in a test:

extract = next(t for t in tools if t.name == "scraper_extract_content")
outcome = extract.invoke({"url": "https://example.com", "formats": ["markdown"]})
if outcome["ok"]:
    print(outcome["result"]["data"]["markdown"])
else:
    print(outcome["error"]["status"], outcome["error"]["message"])

What a tool returns

Tools don't raise on API errors. They return a dict, so the agent can read what went wrong and decide what to do:

  • On success: {"ok": true, "operation": "...", "attempts": 1, "result": {...}}.
  • On failure: {"ok": false, "operation": "...", "attempts": 1, "error": {"status": 429, "code": "...", "message": "...", "retryable": true, ...}}.

status is the API's HTTP status; the Python SDK page lists what each one means. retryable says whether trying again can help.

Pick only the tools you need

Fewer tools make it easier for a model to choose. Pass the operation names you want:

tools = build_langchain_tools(settings=settings, operations=["extract", "map_urls", "search"])
OperationToolWhat it does
extractscraper_extract_contentExtract one URL as Markdown or HTML, now or as a background job.
get_job_resultscraper_get_job_resultGet the state or result of a background extraction.
wait_for_jobscraper_wait_for_jobWait until a background extraction finishes.
list_jobsscraper_list_jobsList earlier extractions.
create_batchscraper_create_batchStart one job for many URLs.
get_batch_statusscraper_get_batch_statusGet a batch's progress and results so far.
wait_for_batchscraper_wait_for_batchWait until a batch finishes.
list_batch_jobsscraper_list_batch_jobsList earlier batches.
create_crawlscraper_create_crawlStart a crawl from one URL.
get_crawl_statusscraper_get_crawl_statusGet a crawl's progress and pages so far.
wait_for_crawlscraper_wait_for_crawlWait until a crawl finishes.
list_crawl_jobsscraper_list_crawl_jobsList earlier crawls.
map_urlsscraper_map_urlsFind the URLs under a site from its sitemap and links.
list_map_jobsscraper_list_map_jobsList earlier map runs.
get_map_jobscraper_get_map_jobGet one map run with its URLs.
searchscraper_searchSearch the web and return ranked results.
list_search_jobsscraper_list_search_jobsList earlier searches.
get_search_jobscraper_get_search_jobGet one search with its results.
get_statisticsscraper_get_statisticsUsage statistics for a period.
get_concurrency_usagescraper_get_concurrency_usageConcurrent requests in use against the plan limit.
health_checkscraper_check_healthCheck that the API is up.

Versions and support

  • The latest version is on PyPI. The same tools are available for CrewAI.
  • Requests send User-Agent: geonode-langchain/<version>, which helps support see which version you use.
  • Questions or problems: contact Geonode.

Was this page helpful?

On this page