Skip to content

Commit d54cb2a

Browse files
committed
fix(stealth): omit focus_control by default
patchright_focus_control defaulted to False, so context_options passed focus_control=False to launch_persistent_context, which patchright builds without that option reject. Both MCP tools crashed since fetch went stealth in 0.5.9. Default to None so the option is omitted unless set. Also refresh the docs home copy for the LLM/MCP story. Bump 0.5.9 -> 0.6.0.
1 parent cb00c41 commit d54cb2a

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "webskrap"
7-
version = "0.5.9"
7+
version = "0.6.0"
88
description = "A Playwright-based Python scraping framework with coherent browser profiles and session controls."
99
readme = "README.md"
1010
requires-python = ">=3.11"

src/webskrap/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ class SessionConfig(BaseModel):
185185
# scheme, reduced motion, and caller-provided extra headers) while still
186186
# avoiding viewport, user-agent, and JavaScript fingerprint patches.
187187
patchright_context_profile: bool = False
188-
# Patchright-specific focus behavior control. Set to None to omit the option
189-
# for Patchright versions that do not accept it.
190-
patchright_focus_control: bool | None = False
188+
# Patchright-specific focus behavior control. Defaults to None so the option
189+
# is omitted entirely; Patchright builds that lack focus_control reject it.
190+
# Set True/False only when targeting a build that accepts the option.
191+
patchright_focus_control: bool | None = None
191192

192193
def launch_options(self) -> dict[str, Any]:
193194
options: dict[str, Any] = {

tests/test_models.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_patchright_context_omits_profile_by_default() -> None:
6161
options = config.context_options(profile)
6262

6363
assert options["no_viewport"] is True
64-
assert options["focus_control"] is False
64+
assert "focus_control" not in options
6565
assert "user_agent" not in options
6666
assert "extra_http_headers" not in options
6767

@@ -84,7 +84,7 @@ def test_patchright_context_profile_applies_native_context_metadata() -> None:
8484
options = config.context_options(profile)
8585

8686
assert options["no_viewport"] is True
87-
assert options["focus_control"] is False
87+
assert "focus_control" not in options
8888
assert options["locale"] == "en-US"
8989
assert options["timezone_id"] == "Europe/Paris"
9090
assert options["color_scheme"] == "dark"
@@ -108,6 +108,24 @@ def test_patchright_focus_control_can_be_omitted() -> None:
108108
assert "focus_control" not in options
109109

110110

111+
def test_patchright_focus_control_omitted_by_default() -> None:
112+
profile = BrowserProfile(name="test")
113+
config = SessionConfig(driver="patchright")
114+
115+
options = config.context_options(profile)
116+
117+
assert "focus_control" not in options
118+
119+
120+
def test_patchright_focus_control_emitted_when_set() -> None:
121+
profile = BrowserProfile(name="test")
122+
config = SessionConfig(driver="patchright", patchright_focus_control=True)
123+
124+
options = config.context_options(profile)
125+
126+
assert options["focus_control"] is True
127+
128+
111129
def test_headless_chromium_gets_simulated_screen() -> None:
112130
config = SessionConfig(driver="patchright", channel="chrome", headless=True)
113131

web/content/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WebSkrap
22

3-
Async-first Python scraping on Playwright. Coherent profiles, persistent sessions, resource routing, and Patchright-powered stealth.
3+
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.
44

55
> **⚠ Usage boundary** — WebSkrap does not include CAPTCHA solving, login-wall bypassing, credential bypassing, or access-control circumvention. Use it only on targets you are allowed to access.
66
@@ -38,4 +38,5 @@ asyncio.run(main())
3838
- [Profiles](/docs/user-guide/profiles)
3939
- [Stealth](/docs/user-guide/stealth)
4040
- [CLI](/docs/user-guide/cli)
41+
- [MCP Server](/docs/user-guide/mcp)
4142
- [API Reference](/docs/api-reference)

0 commit comments

Comments
 (0)