Skip to content
kacigayaPublic

Repository files navigation

WebSkrap logo

WebSkrap

Async-first Python scraping on Playwright, with persistent sessions, resource routing, Patchright stealth, web search, a CLI, and an MCP server for agents.

WebSkrap version on PyPI Python 3.11 or newer Playwright 1.49 or newer Apache 2.0 License

Install

pip install webskrap
webskrap install

Quickstart

import asyncio

from webskrap import WebSkrapClient


async def main() -> None:
    async with WebSkrapClient() as client:
        result = await client.fetch("https://example.com")
        print(result.status, result.title)
        print(result.text[:200])


asyncio.run(main())

For deferred content, pass ready_selector="#content" to a Python fetch or --ready-selector '#content' to CLI fetch. Both MCP fetch tools accept ready_selector too. The selector must become visible after consent dismissal. Known DataDome and Cloudflare challenge pages raise blocked; WebSkrap does not retry or solve them. Ordinary HTTP errors still return ok=False.

Search

A search loads the engine's results page in the same stealth browser and returns the organic hits. Click-tracking redirects are unwrapped, so each url is the destination itself. Bing is the default; use engine="ddg" for DuckDuckGo's HTML endpoint. Google is not offered.

async with WebSkrapClient() as client:
    result = await client.search("example domain", max_results=5)
    for hit in result.hits:
        print(hit.title, hit.url)
webskrap search "example domain" --engine ddg --max-results 10 --format json

When an engine distrusts the exit address it serves a bot challenge. That comes back as a blocked error, not as zero hits. Switch engine, reuse a persistent profile, or change the exit IP. WebSkrap does not retry and does not solve CAPTCHAs.

Visual browser interaction

Agents can see the rendered viewport and interact by coordinates, including canvas and controls missing from the accessibility tree. MCP browser_view returns a PNG image directly; browser_mouse clicks, moves, scrolls, or drags. browser_insert_text inserts literal text into the focused control.

webskrap browser open https://example.com
webskrap browser view viewport.png --format json
# Open the returned PNG with your agent's image viewer, then choose coordinates.
webskrap browser mouse click 120 80
webskrap browser insert-text "hello"
webskrap browser press Enter
webskrap browser view viewport.png --format json
webskrap browser close

Coordinates are CSS pixels from the original image's top-left. Take a fresh view after scrolling or page changes. Headless Chromium needs no Xvfb for this; the agent's client and model must support image input.

Documentation

The agent skill is available at .agents/skills/webskrap/SKILL.md, .claude/skills/webskrap/SKILL.md, and .codex/skills/webskrap/SKILL.md. The file lives in .agents/skills/webskrap/. The .claude and .codex folders link to it, and every folder links to the root references/. The checkout must support symbolic links. On Windows, enable Developer Mode and Git's core.symlinks before cloning.

Security

Persistent browser sessions keep Chromium's OS sandbox, store their profiles 0700, and confine MCP screenshot output to ./webskrap-output. See SECURITY.md for the security model and how to report a vulnerability, and CHANGELOG.md for what changed.

Contributing

See CONTRIBUTING.md for setup, checks, and pull request expectations.

Releases

Used by

Contributors

Languages