Skip to main content

LangChain tools for the MrScraper web-scraping API

Project description

langchain-mrscraper

LangChain integration package for the MrScraper SDK.

This package exposes MrScraper capabilities as LangChain tools so agents can:

  • Fetch rendered HTML from protected websites
  • Scrape Google SERP (search results) synchronously
  • Create AI scrapers from natural-language prompts
  • Rerun AI/manual scrapers (single and bulk)
  • List and fetch scraping results

Installation

pip install -U langchain-mrscraper

or:

uv add langchain-mrscraper

mrscraper-sdk is installed automatically as a dependency, so users do not need to install it separately.

Quick start

import os
from langchain_mrscraper import MrScraperToolkit

os.environ["MRSCRAPER_API_KEY"] = "your-token"

tools = MrScraperToolkit().get_tools()

Use with an agent

from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from langchain_mrscraper import MrScraperToolkit

tools = MrScraperToolkit(token="your-token").get_tools()
agent = create_react_agent(ChatOpenAI(model="gpt-4o-mini"), tools)

Available tools

  • mrscraper_google_serp
  • mrscraper_fetch_html
  • mrscraper_create_scraper
  • mrscraper_rerun_ai_scraper
  • mrscraper_bulk_rerun_ai_scraper
  • mrscraper_rerun_manual_scraper
  • mrscraper_bulk_rerun_manual_scraper
  • mrscraper_get_all_results
  • mrscraper_get_result_by_id

API styles

You can initialize via:

  • MrScraperToolkit(...).get_tools() (recommended)
  • load_mrscraper_tools(...) convenience function
  • per-tool constructors with token="..." or mrscraper_api_key="..."
  • environment variables MRSCRAPER_API_KEY (preferred) or MRSCRAPER_API_TOKEN

Tools vs. loaders

This integration is intentionally tools-first. MrScraper endpoints are action-oriented (fetch, create, rerun, list, retrieve) and best represented as BaseTool methods that agents can call explicitly.

A document loader abstraction is usually better when the primary job is deterministic "URL -> documents" ingestion into vector stores. MrScraper can support that in a separate package later, but this package should remain focused on agent tools.

Testing

pytest tests/unit_tests -v

Integration smoke tests (real API):

MRSCRAPER_API_KEY=your-token pytest tests/integration_tests -m integration -v

Local release workflow

  1. Update version in pyproject.toml
  2. Build: python -m build
  3. Upload to TestPyPI: twine upload --repository testpypi dist/*
  4. Verify install from TestPyPI
  5. Upload to PyPI: twine upload dist/*

Docs files for LangChain PR

  • Provider page: docs/providers/mrscraper.mdx
  • Tool pages: docs/tools/*.mdx (one page per tool)

These are prepared to submit to langchain-ai/docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_mrscraper-0.2.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_mrscraper-0.2.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_mrscraper-0.2.1.tar.gz.

File metadata

  • Download URL: langchain_mrscraper-0.2.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for langchain_mrscraper-0.2.1.tar.gz
Algorithm Hash digest
SHA256 9f5e80eed199d3b79b83dba70d650f2085f17dd5269913593aca034c38ab0935
MD5 901732f9fd7c815a070125fbc44c11bb
BLAKE2b-256 0ecb5c0867e4f5c6b0b56aa761e11d3a649debd7511c43739fb6e524de58722d

See more details on using hashes here.

File details

Details for the file langchain_mrscraper-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mrscraper-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b8ea829c3806d755f72978b16b3d481049c91a63912a7e5aa71b663d91e2bf3
MD5 be26aa46c34d4194ec7b5e1e82e09883
BLAKE2b-256 e618aaf0d564fbcdd65bf71d34e70999933ecf734f5a3a975e6391773f174254

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page