
PyScrappy
io.github.mldsveda由 GitHub 帳號 mldsveda 發布v1.5.9更新於 Oct 24, 2026
Web-scraping toolkit with 22 tools for structured web data as JSON for AI agents.
發布方自己的服務:Scrappy Cloud Browser
概覽
PyScrappy 是一個本機 MCP 伺服器,透過 20 多個擷取工具把網站內容轉成結構化、適合大型語言模型使用的文字、連結、表格與中繼資料。
- 可以做什麼
- 擷取任意 URL,取出文字、連結、圖片、表格與中繼資料,可選用 CSS 選擇器與 Playwright 渲染 JavaScript,並支援網站地圖爬取與多頁面、多網站並行擷取,輸出 Markdown、JSON 或 DataFrame。執行針對特定網站的擷取器,涵蓋維基百科、新聞來源、股票、GitHub、Hacker News、天氣、加密貨幣、匯率、辭典、圖片、圖書與職缺搜尋,以及 Amazon、Newegg、IKEA 等電商網站。取得 YouTube、SoundCloud、Zomato 與 Uber Eats 等社群、媒體與餐飲資料。透過 OMDb 查詢電影資訊。列出可用的擷取器,並呼叫第三方套件註冊的外掛擷取器。
- 適用情境
- 適合助理需要把即時網頁內容當成乾淨結構化資料使用的情境,例如彙整新聞標題、查詢股票行情或擷取商品列表,而不必自行撰寫擷取程式。也適合對同一網站的多个頁面進行資料蒐集與研究。
- 執行需求
- 以本機 Python 程序執行,MCP 伺服器需要 Python 3.10 或更新版本,透過 mcp 附加元件安裝,並以 pyscrappy-mcp 指令或 python -m pyscrappy.mcp 啟動。選用附加元件提供 Playwright 瀏覽器渲染、DataFrame、Parquet 與 Excel 支援。電影查詢工具需要免費的 OMDb API 金鑰,透過 OMDB_API_KEY 環境變數傳入。需要網路存取;代理或擷取 API 服務為選用項目。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 PyScrappy,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Adaptive Python web scraping toolkit (self-healing, stealth)
+ MCP server for AI agents
[Python 3.9+] [PyPI Latest Release] [License: MIT] [Downloads] [Glama quality] [Documentation] [MCP Toplist]
PyScrappy is an AI-native web scraping toolkit that turns websites into structured, LLM-ready data. Use it as a Python library or expose it as an MCP server for AI agents.
📖 Documentation: pyscrappy.vercel.app
Key features
- Generic scraper — give it any URL, get back structured text, links, images, tables, and metadata
- LLM-ready output —
.to_markdown()turns any result into clean Markdown; also.to_json()and.to_dataframe() - MCP server — expose the scrapers as tools for AI agents (Claude, Cursor, local LLMs, …)
- JS rendering — optional Playwright backend for JavaScript-heavy sites
- Custom selectors — pass CSS selectors to extract exactly what you need
- Chainable
Selector— navigate HTML directly with CSS/XPath,find_all,find_by_text, andfind_similar(Scrapy/BeautifulSoup-style) - Adaptive (self-healing) selectors — remember an element and relocate it by similarity when a site changes its markup, so scrapers don't silently break
- Concurrent scraping —
scrape_many/scrape_allrun scrapes in parallel - Sitemap crawling — enumerate and scrape a whole site from its
sitemap.xml(index + gzip aware) - Proxy & scraping-API support — route through a proxy or ScraperAPI/ScrapeOps for blocked sites
- TLS-fingerprint impersonation —
impersonate="chrome"gets past anti-bot filters that block plain clients (optionalcurl_cffibackend) - Command-line extract —
pyscrappy extract <url> out.mdscrapes a URL straight to a file, no code - Retry & rate-limiting — built-in exponential backoff and per-domain rate limiting
- Type-safe — full type hints,
py.typedmarker - 20+ built-in scrapers — Wikipedia, IMDB, stocks, news, GitHub, Amazon/IKEA, YouTube, and more
Installation
Optional extras:
For AI agents
PyScrappy ships an MCP server that exposes its scrapers as tools, so an agent (Claude, Cursor, an OpenAI agent, a local LLM) can pull structured web data from any URL and hand it straight to the model:
Then just ask: "use pyscrappy to summarize the latest headlines from bbc.com." See MCP server for the full setup and tool list.
Local models (Ollama), no MCP host needed
Ollama can't talk MCP on its own, so normally you'd run a host (Goose, Cline, …) in between. PyScrappy skips that with a built-in agent that talks to Ollama directly and lets a local model call the scrapers as tools:
It exposes the same 22 tools as the MCP server. The only requirement is a model
that supports tool calling (Llama 3.1, Qwen 2.5, Mistral, …); how well it
picks the right tool is up to the model. Point it at a remote Ollama with
--host, and pass -v to see each tool call.
MCP server (use PyScrappy from an AI agent)
PyScrappy ships an optional Model Context Protocol server, so an AI agent (e.g. Claude) can call PyScrappy's scrapers as tools and get structured web data back.
[PyScrappy MCP server]The MCP extra installs the standalone fastmcp package and requires Python 3.10
or newer. On Python 3.9 the core scraping library still works, but the MCP server
is unavailable.
This installs the pyscrappy-mcp command. It uses stdio by default for local MCP
clients; Streamable HTTP and legacy SSE are available for remote deployments:
You can also run the stdio server with python -m pyscrappy.mcp.
Register with Claude Code
Register with Claude Desktop
Add to your claude_desktop_config.json and restart the app:
Tip: Claude Desktop does not inherit your shell
PATH. Ifpyscrappy-mcpis not found, use the absolute path to the command (e.g. the one printed bywhich pyscrappy-mcp).
Available tools
The server exposes 20+ tools. The most common ones are scrape_url (any
URL → text, links, images, tables, metadata), scrape_wikipedia,
scrape_stock, scrape_news, and search_github — plus many more
covering image/YouTube/LinkedIn/Hacker News/book search, weather, crypto,
currency, dictionary, Amazon/Newegg/IKEA/SoundCloud, IMDB, and Zomato/Uber Eats.
To see the full, live list, ask the agent to call the list_available_scrapers
tool, or from a shell:
The lookup_movie tool needs a free OMDb API
key. Pass it to the server through your MCP client config, e.g. for Claude Desktop:
Once registered, just ask the agent naturally, e.g. "use pyscrappy to get the latest headlines from bbc.co.uk and the AAPL stock quote."
Built-in scrapers
PyScrappy ships 24 built-in scrapers, and every one that works without a proxy is also exposed as an MCP tool.
A few of them:
GenericScraper— scrape any URL with auto-extraction (text, links, images, tables, metadata)- Data / research —
WikipediaScraper,StockScraper(Yahoo Finance),NewsScraper(RSS/Atom),GitHubScraper,HackerNewsScraper, plus weather, crypto, currency, dictionary, image, LinkedIn-jobs, and book search - E-commerce —
AmazonScraper,NeweggScraper,IKEAScraper - Social / media / food —
YouTubeScraper, SoundCloud, Zomato, Uber Eats (Instagram / Twitter / Spotify also ship, but are blocked and need a proxy)
…and many more. To see the full, live list:
IMDBScraper (lookup_movie) is the one exception that needs a key — a free
OMDb OMDB_API_KEY (see the
MCP config above for how to pass it).
Plugins
PyScrappy is extensible: you can add your own scrapers, and third parties can
ship them as standalone pyscrappy-<name> packages. A registered scraper works
everywhere a built-in does, including the MCP server and the pyscrappy chat
agent, with no change to PyScrappy core.
In your own code — register with the decorator:
As a distributable package — advertise an entry point in your
pyproject.toml, and PyScrappy discovers it once your package is installed:
After pip install pyscrappy-reddit, the scraper shows up in
list_scrapers(), and an AI agent can call it via the scrape_with MCP tool —
no core change required.
First-class MCP tools (optional). Add an mcp_tools mapping and your scraper
becomes a dedicated, typed MCP tool instead of only being reachable through the
generic scrape_with — its schema is derived from the method signature, so
agents get proper named arguments:
See the plugin template for a complete, copyable starting point, and the plugin guide for the full walkthrough.
Quick start
Scrape any URL → clean, LLM-ready Markdown
Prefer raw fields? Every result is a ScrapeResult with .data (a list of
dicts):
Custom CSS selectors
Navigate HTML with Selector
When you want to traverse markup directly (Scrapy/BeautifulSoup-style) rather than
get back structured dicts, use Selector:
css() / xpath() return a SelectorList with .get() / .getall() / .text().
find_similar() locates elements with the same tag and overlapping classes, handy
for pulling every card/row once you've found one.
Adaptive (self-healing) selectors
A hard-coded CSS selector silently breaks the day a site changes its markup. Adaptive selectors survive that: save a fingerprint of the element the first time, and if the selector later matches nothing, relocate it by structural and textual similarity instead of returning empty.
How the relocation decides — and where it's stronger than a naive similarity match:
- Weighted signals, not a flat average. A stable
id/data-*hook counts far more than a sibling-tag list, so weak signals can't outvote strong ones. - Anchor-relative. It remembers the nearest stable ancestor (an id'd /
data-*container) and depth, so it survives layout reshuffles that move absolute positions. - Volatility-aware text. Prices, dates, and counts are down-weighted, so healing stays reliable on exactly the fields that change most between scrapes.
- Confidence-scored.
SelectorList.adaptive_confidence(0-100) tells you how sure the relocation was;threshold=sets the minimum to accept. - Contract-enforced (opt-in). Pass
expect=<callable>to require the healed element to satisfy an invariant (e.g. "text looks like a price"). A heal that clears the threshold but fails the contract is rejected, so structural similarity alone never redefines what a field means.
A heal is a change to what a selector resolves to, so every accepted heal is
recorded. The store keeps an append-only audit log (adaptive.heal.ndjson
beside the fingerprint store) with the confidence, the runner-up gap, and the
before/after fingerprint, readable via store.heal_log() — so drift stays
observable instead of being silently absorbed. For an at-a-glance summary,
store.heal_report() aggregates the log into one row per selector (heal count,
latest/lowest/average confidence, when it last healed), sorted most-healed first
— so the selectors that have drifted the most, and the shakiest relocations
(lowest confidence), surface at the top for a human to review.
Fingerprints persist in a small JSON store (~/.pyscrappy/adaptive.json by
default, or $PYSCRAPPY_HOME), namespaced by site so the same adaptive_id on
two sites never collides. Adaptive is entirely opt-in: without adaptive=True, a
broken selector still just returns empty, exactly as before.
Site-specific scrapers
Every built-in scraper follows the same pattern — instantiate, scrape(...),
read result.data (or .to_dataframe() / .to_markdown()):
Each scraper has its own arguments (Wikipedia, stocks, IMDB, news, YouTube, Amazon/Newegg/IKEA, Uber Eats, and more — see the full list). For per-scraper arguments and examples, see the documentation.
From the command line
Scrape a URL straight to a file without writing any code — the output format is inferred from the file extension:
Configuration
Proxies and blocked sites
Some sites (e.g. eBay, Instagram, Twitter/X, Spotify) block direct automated requests. PyScrappy supports two ways to get through them.
A proxy (or a rotating list) — applies to both the HTTP and browser backends:
A scraping-API service (ScraperAPI, ScrapeOps, ScrapingBee) — routes requests through the service, which handles proxies and anti-bot challenges for you:
This is the reliable way to use the scrapers marked "needs proxy" above.
TLS-fingerprint impersonation — many anti-bot systems block a plain HTTP
client by its TLS/JA3 fingerprint before serving any content. Set impersonate
to mimic a real browser's fingerprint and get past that class of block without a
headless browser:
Impersonation works on both the sync and async paths (async uses
curl_cffi's AsyncSession), so you can combine stealth with high-throughput
async scraping. All the usual retry, rate-limiting, caching, and robots handling
still apply.
Concurrent scraping
Scraping is I/O-bound, so running several scrapes at once parallelizes the
network waits. scrape_many runs one scraper over many inputs; scrape_all
runs a mix of scrapers together. Both preserve input order.
Sitemap crawling
Pagination follows next-page links; a sitemap enumerates a whole site's URLs
directly. GenericScraper can read /sitemap.xml (discovered from robots.txt
Sitemap: directives, or the conventional path), follow a <sitemapindex> into
its child sitemaps, and scrape every listed page.
Handles <urlset> leaves and <sitemapindex> files (recursing one level),
gzip-compressed sitemaps (.xml.gz), and de-duplicates URLs. Fetches go through
the usual rate-limiting, caching, proxy, and stealth machinery, and the fan-out
reuses scrape_all. max_urls caps the crawl (a sitemap can list tens of
thousands of URLs, so it's required for scrape_sitemap).
Response caching
Set cache_ttl to a positive number of seconds to cache successful GET
responses. Repeated requests for the same URL (and query params) within the TTL
are served from cache, skipping both the network and the rate limiter. Caching
is disabled by default (cache_ttl=0).
The cache is in memory and shared across scraper instances in the same process
(so it also speeds up repeated calls through the MCP server), and is cleared
when the process exits. Call HttpClient.clear_cache() to empty it manually.
It is LRU-bounded: at most cache_max_size live entries (default 512),
with the least-recently-used entry evicted once the cap is reached. So a
long-running process (e.g. the MCP server) that fetches many distinct URLs stays
bounded rather than growing until restart. Raise or lower the cap as needed:
Persistent (on-disk) cache. Set cache_dir to also persist responses to
disk, so cache hits survive across process restarts and separate runs — useful
for re-running a scrape or a CLI job without re-fetching. The in-memory cache
still fronts it for speed; a disk hit is promoted back into memory.
The on-disk cache is bounded too: each write prunes expired entries and trims the
oldest past cache_dir_max_size (default 512), so a cache_dir doesn't grow
one file per distinct URL forever.
clear_cache() empties the in-memory cache; the on-disk cache persists by
design — delete its cache_dir to clear it.
Observability hooks
For long crawls, pass lightweight callbacks to watch requests live (progress bars, metrics) without turning on logging:
on_request(url)fires once before a URL is fetched (not on a cache hit).on_retry(url, attempt, delay, error)fires before each backoff sleep.on_cache_hit(url)fires when a request is served from cache.
All three are best-effort: a callback that raises is logged at debug and never breaks the scrape. They fire on both the sync and async paths.
Dependencies
Required: httpx, beautifulsoup4, lxml
Optional: playwright (JS rendering), pandas (DataFrames), fastmcp
(MCP server, Python 3.10+)
License
Contributing
All contributions welcome. See Issues.
This package is for educational and research purposes.
來源:README.md,提交 4e99e92
工具
0版本歷史
1- v1.5.9最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分