Skip to content

Commit 1173280

Browse files
committed
docs: improve search engine visibility
1 parent 6c024b1 commit 1173280

25 files changed

Lines changed: 578 additions & 12 deletions

web/content/api-reference.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: WebSkrap Python API Reference
3+
description: Reference for WebSkrapClient, WebSkrapSession, FetchResult, SessionConfig, BrowserProfile, resource policies, and proxy configuration.
4+
---
5+
16
# API Reference
27

38
> Full typed signatures and docstrings live in the source. Browse them on [GitHub](https://github.com/kacigaya/webskrap/tree/main/src/webskrap).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: WebSkrap vs Playwright for Python Web Scraping
3+
description: Compare WebSkrap and Playwright for Python web scraping, browser automation, persistent sessions, resource routing, Patchright stealth, and MCP agent tools.
4+
---
5+
6+
# WebSkrap vs Playwright for Python Web Scraping
7+
8+
Playwright is a powerful browser automation library. WebSkrap builds on top of Playwright and Patchright to provide a higher-level Python web scraping toolkit.
9+
10+
## When Playwright is enough
11+
12+
Use Playwright directly when you need full low-level browser control and want to write the whole scraping workflow yourself.
13+
14+
```python
15+
from playwright.async_api import async_playwright
16+
```
17+
18+
This is ideal for custom browser automation, testing flows, or highly specific scraping logic.
19+
20+
## What WebSkrap adds
21+
22+
WebSkrap packages common scraping needs into a smaller API:
23+
24+
| Capability | Playwright | WebSkrap |
25+
| --- | --- | --- |
26+
| Browser automation | Yes | Yes, via Playwright/Patchright |
27+
| One-shot fetch result object | Manual | Built in |
28+
| Persistent scraping sessions | Manual setup | Built in |
29+
| Browser profiles | Manual setup | Built in |
30+
| Resource routing presets | Manual setup | Built in |
31+
| Patchright stealth path | Separate integration | Built in |
32+
| MCP server for agents | Manual | Built in |
33+
| CLI JSON fetch output | Manual | Built in |
34+
35+
## Example WebSkrap fetch
36+
37+
```python
38+
import asyncio
39+
from webskrap import WebSkrapClient
40+
41+
async def main() -> None:
42+
async with WebSkrapClient() as client:
43+
result = await client.fetch("https://example.com")
44+
print(result.title)
45+
46+
asyncio.run(main())
47+
```
48+
49+
## Recommendation
50+
51+
Use Playwright directly when you need total browser control. Use WebSkrap when you want a Python web scraping package with sensible defaults, reusable sessions, profiles, resource policy, CLI output, and MCP tools.
52+
53+
## Related docs
54+
55+
- [Python Web Scraping with WebSkrap](/docs/guides/python-web-scraping)
56+
- [Client API](/docs/user-guide/client)
57+
- [Stealth](/docs/user-guide/stealth)
58+
- [MCP Server](/docs/user-guide/mcp)

web/content/development.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Developing WebSkrap
3+
description: Development notes for contributing to WebSkrap, running tests, browser integrations, and maintaining the Python scraping package.
4+
---
5+
16
# Development
27

38
Clone the repository:

web/content/getting-started/installation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Install WebSkrap for Python Web Scraping
3+
description: Install WebSkrap, Playwright browsers, Patchright support, and the CLI for Python web scraping and browser automation.
4+
---
5+
16
# Installation
27

38
Install WebSkrap from PyPI:

web/content/getting-started/quickstart.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Python Web Scraping Quickstart
3+
description: Start scraping web pages with WebSkrap, Playwright, async Python, screenshots, persistent browser state, and clean fetch results.
4+
---
5+
16
# Quickstart
27

38
## One-shot fetch
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: LLM Web Scraping and MCP Server for AI Agents
3+
description: Use WebSkrap as an MCP web scraping server for LLM agents that need clean page text from live browser sessions instead of raw HTML.
4+
---
5+
6+
# LLM Web Scraping and MCP Server for AI Agents
7+
8+
WebSkrap includes an MCP server so AI agents can fetch live web pages with a browser-backed scraper and receive clean page text instead of raw HTML.
9+
10+
This is useful for coding agents, research agents, and automation workflows that need current page content but should avoid flooding the language model with scripts, styles, and markup noise.
11+
12+
## Start the MCP server
13+
14+
```bash
15+
pip install webskrap
16+
webskrap install
17+
webskrap-mcp
18+
```
19+
20+
The MCP server exposes tools such as `fetch`, `stealth_fetch`, and `doctor`.
21+
22+
## CLI output for agents
23+
24+
The CLI also returns bounded JSON that is easy for agents to parse:
25+
26+
```bash
27+
webskrap fetch https://example.com --format json --max-chars 12000
28+
```
29+
30+
The JSON includes `url`, `final_url`, `status`, `ok`, `title`, `headers`, `text`, `text_length`, `text_truncated`, and `elapsed_ms`.
31+
32+
## Why clean text matters
33+
34+
Raw HTML can be thousands of tokens of boilerplate. WebSkrap focuses on browser-backed fetching with output formats that are easier for LLMs and agents to consume.
35+
36+
## Related docs
37+
38+
- [MCP Server](/docs/user-guide/mcp)
39+
- [CLI](/docs/user-guide/cli)
40+
- [Stealth](/docs/user-guide/stealth)
41+
- [API Reference](/docs/api-reference)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Python Web Scraping with WebSkrap
3+
description: Learn Python web scraping with WebSkrap, Playwright, browser profiles, persistent sessions, and clean text extraction for modern JavaScript pages.
4+
---
5+
6+
# Python Web Scraping with WebSkrap
7+
8+
WebSkrap is a Python web scraping toolkit for pages that need a real browser. It wraps Playwright with an async API, reusable browser sessions, coherent browser profiles, resource routing, and optional Patchright-powered stealth sessions.
9+
10+
Use it when a simple `requests` or `BeautifulSoup` script cannot see the content because the site renders data with JavaScript, relies on browser storage, or needs a realistic browser context.
11+
12+
## Install
13+
14+
```bash
15+
pip install webskrap
16+
webskrap install
17+
```
18+
19+
## Scrape a page
20+
21+
```python
22+
import asyncio
23+
24+
from webskrap import WebSkrapClient
25+
26+
27+
async def main() -> None:
28+
async with WebSkrapClient() as client:
29+
result = await client.fetch("https://example.com")
30+
31+
print(result.status)
32+
print(result.final_url)
33+
print(result.title)
34+
print(result.text[:500])
35+
36+
37+
asyncio.run(main())
38+
```
39+
40+
`FetchResult` includes the final URL, status, headers, cookies, title, HTML/text output, timings, and optional screenshot path.
41+
42+
## Why use a browser scraper?
43+
44+
Modern websites often ship a small HTML shell and fill it with JavaScript. WebSkrap launches Chromium through Playwright so your scraper sees the page after browser navigation, redirects, cookies, and client-side rendering.
45+
46+
Common use cases:
47+
48+
- Scrape JavaScript-heavy pages in Python.
49+
- Build data collection scripts that need browser state.
50+
- Reuse login or consent state with persistent sessions on sites you are allowed to access.
51+
- Return clean page data to LLM agents through MCP.
52+
- Capture screenshots for debugging.
53+
54+
## Next steps
55+
56+
- [Quickstart](/docs/getting-started/quickstart)
57+
- [Client API](/docs/user-guide/client)
58+
- [Persistent sessions](/docs/user-guide/sessions)
59+
- [Browser profiles](/docs/user-guide/profiles)
60+
- [Resource policy](/docs/user-guide/resource-policy)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Scrape JavaScript Pages with Playwright and Python
3+
description: Use WebSkrap to scrape JavaScript-rendered pages in Python with Playwright, Chromium, wait conditions, screenshots, and resource routing.
4+
---
5+
6+
# Scrape JavaScript Pages with Playwright and Python
7+
8+
Many web pages do not expose their main content in the initial HTML. WebSkrap uses Playwright and Chromium so Python scripts can scrape JavaScript-rendered pages after the browser has loaded them.
9+
10+
## Browser-backed fetch
11+
12+
```python
13+
import asyncio
14+
15+
from webskrap import WebSkrapClient
16+
17+
18+
async def main() -> None:
19+
async with WebSkrapClient() as client:
20+
result = await client.fetch(
21+
"https://example.com",
22+
wait_until="domcontentloaded",
23+
timeout_ms=30_000,
24+
screenshot="debug.png",
25+
)
26+
27+
print(result.ok)
28+
print(result.title)
29+
print(result.screenshot_path)
30+
31+
32+
asyncio.run(main())
33+
```
34+
35+
## Faster scraping with resource routing
36+
37+
Images, fonts, media, and trackers often slow scraping down. WebSkrap supports resource policies so you can load only what the page needs.
38+
39+
```python
40+
from webskrap import ResourcePolicy, SessionConfig
41+
42+
config = SessionConfig(resource_policy=ResourcePolicy.LITE)
43+
```
44+
45+
Use `DOCUMENTS` when you only need top-level document HTML. Use `LITE` when pages need scripts or styles but not heavy media.
46+
47+
## Debug JavaScript pages
48+
49+
For tricky pages, keep a headed browser open:
50+
51+
```python
52+
from pathlib import Path
53+
from webskrap import SessionConfig
54+
55+
config = SessionConfig(
56+
headless=False,
57+
user_data_dir=Path(".webskrap/debug-profile"),
58+
)
59+
```
60+
61+
Then inspect what the browser actually sees before changing the scraper.
62+
63+
## Related docs
64+
65+
- [Quickstart](/docs/getting-started/quickstart)
66+
- [Resource policy](/docs/user-guide/resource-policy)
67+
- [Sessions](/docs/user-guide/sessions)
68+
- [CLI](/docs/user-guide/cli)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Web Crawling with Python and WebSkrap
3+
description: Build browser-aware Python web crawlers with WebSkrap, async concurrency, persistent sessions, resource policies, and safe crawling boundaries.
4+
---
5+
6+
# Web Crawling with Python and WebSkrap
7+
8+
WebSkrap is useful for browser-aware web crawling when each URL may need JavaScript rendering, cookies, redirects, or a realistic browser profile.
9+
10+
A crawler should still be polite and bounded. Respect robots policies where applicable, rate limits, terms of service, and access controls. WebSkrap does not include CAPTCHA solving or access-control bypassing.
11+
12+
## Simple async crawl pattern
13+
14+
```python
15+
import asyncio
16+
17+
from webskrap import WebSkrapClient
18+
19+
URLS = [
20+
"https://example.com",
21+
"https://example.com/about",
22+
]
23+
24+
25+
async def main() -> None:
26+
async with WebSkrapClient() as client:
27+
results = await asyncio.gather(*(client.fetch(url) for url in URLS))
28+
29+
for result in results:
30+
print(result.status, result.final_url, result.title)
31+
32+
33+
asyncio.run(main())
34+
```
35+
36+
## Crawl with sessions
37+
38+
Use sessions when multiple pages belong to the same site and should share browser state.
39+
40+
```python
41+
from pathlib import Path
42+
from webskrap import SessionConfig, WebSkrapClient
43+
44+
config = SessionConfig(user_data_dir=Path(".webskrap/crawl-profile"))
45+
```
46+
47+
Persistent sessions can keep cookies and local storage between fetches for sites you are authorized to access.
48+
49+
## Practical crawler tips
50+
51+
- Keep concurrency low until you understand a site.
52+
- Use resource policies to avoid downloading heavy assets.
53+
- Store `final_url` to detect redirects and canonical pages.
54+
- Capture screenshots only for debugging because they add cost.
55+
- Log status codes, titles, timings, and failures.
56+
57+
## Related docs
58+
59+
- [Client API](/docs/user-guide/client)
60+
- [Sessions](/docs/user-guide/sessions)
61+
- [Profiles](/docs/user-guide/profiles)
62+
- [Resource policy](/docs/user-guide/resource-policy)

web/content/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: WebSkrap Documentation
3+
description: Documentation for WebSkrap, a Python web scraping and browser automation toolkit built on Playwright, Patchright, persistent sessions, resource routing, and MCP.
4+
---
5+
16
# WebSkrap
27

38
Async-first Python scraping on Playwright that also works as a web tool for LLMs and agents. You get coherent browser profiles, persistent sessions, resource routing, and Patchright-powered stealth. The MCP server runs that same stealth path, so agents get live pages back as plain text instead of raw HTML.

0 commit comments

Comments
 (0)