webskrap 3.2.0__tar.gz → 3.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {webskrap-3.2.0 → webskrap-3.2.1}/.gitignore +1 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/CHANGELOG.md +9 -1
- {webskrap-3.2.0 → webskrap-3.2.1}/PKG-INFO +1 -1
- {webskrap-3.2.0 → webskrap-3.2.1}/pyproject.toml +1 -1
- {webskrap-3.2.0 → webskrap-3.2.1}/scripts/driver_parity.py +7 -108
- {webskrap-3.2.0 → webskrap-3.2.1}/uv.lock +1 -1
- {webskrap-3.2.0 → webskrap-3.2.1}/.agents/skills/webskrap/SKILL.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/.agents/skills/webskrap/references/cli.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/.agents/skills/webskrap/references/mcp.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/.agents/skills/webskrap/references/python-api.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/.claude/skills/webskrap/SKILL.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/.codex/skills/webskrap/SKILL.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/.gitattributes +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/CONTRIBUTING.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/LICENSE +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/README.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/SECURITY.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/benchmarks.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/docs/design/cdp-driver.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/docs/migration-3.0.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/scripts/live_stealth_report.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/__init__.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/browser_cli.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/browser_session.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/cdp.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/cdp_dom.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/cdp_session.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/cdp_setup.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/challenges.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/cli.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/cli_output.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/client.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/consent.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/diagnostics.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/display.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/errors.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/fetch_runtime.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/guide.md +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/human.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/install.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/mcp_server.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/models.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/parsing.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/paths.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/profiles.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/proxy_auth.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/py.typed +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/search.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/text_search.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/src/webskrap/urls.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/conftest.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/accepted-202.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/akamai-invalid-url-400.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/akamai-reference-403.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/akamai-sec-cpt.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/api-403.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/article-access-denied.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/cloudflare-1020.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/cloudflare-custom-block.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/blocks/not-found-404.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/search/bing.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/search/bing_challenge.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/search/bing_no_results.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/search/ddg.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/search/ddg_challenge.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/fixtures/search/ddg_no_results.html +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/live_stealth_helpers.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_bot_detection.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_bot_detection_headless.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_browser_cli.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_browser_integration.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_browser_session_unit.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_browser_vision.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_cdp.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_cdp_browser.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_cdp_child_targets.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_cdp_session.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_challenges.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_cli.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_client_unit.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_consent.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_consent_live.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_diagnostics.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_display.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_docs.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_errors.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_fetch_runtime.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_human.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_install.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_live_stealth_helpers.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_live_stealth_report.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_mcp.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_mcp_efficiency.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_models.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_parsing.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_paths.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_profiles.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_search.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_search_live.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_text_search.py +0 -0
- {webskrap-3.2.0 → webskrap-3.2.1}/tests/test_urls.py +0 -0
|
@@ -9,6 +9,13 @@ history, so they summarize each release rather than list every change.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [3.2.1] - 2026-10-26
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
|
|
16
|
+
- `scripts/driver_parity.py` no longer offers `--click`. The script only
|
|
17
|
+
measures whether a target challenges each driver.
|
|
18
|
+
|
|
12
19
|
## [3.2.0] - 2026-10-26
|
|
13
20
|
|
|
14
21
|
### Added
|
|
@@ -929,7 +936,8 @@ entries below.
|
|
|
929
936
|
|
|
930
937
|
Earlier releases (0.1.0 - 0.4.9) are recorded in the git history and tags only.
|
|
931
938
|
|
|
932
|
-
[Unreleased]: https://github.com/kacigaya/webskrap/compare/v3.2.
|
|
939
|
+
[Unreleased]: https://github.com/kacigaya/webskrap/compare/v3.2.1...HEAD
|
|
940
|
+
[3.2.1]: https://github.com/kacigaya/webskrap/compare/v3.2.0...v3.2.1
|
|
933
941
|
[3.2.0]: https://github.com/kacigaya/webskrap/compare/v3.1.0...v3.2.0
|
|
934
942
|
[3.1.0]: https://github.com/kacigaya/webskrap/compare/v3.0.1...v3.1.0
|
|
935
943
|
[3.0.1]: https://github.com/kacigaya/webskrap/compare/v3.0.0...v3.0.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: webskrap
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.1
|
|
4
4
|
Summary: Async Python scraping on Chromium over its own CDP client, with coherent browser profiles and session controls.
|
|
5
5
|
Project-URL: Homepage, https://github.com/kacigaya/webskrap
|
|
6
6
|
Project-URL: Repository, https://github.com/kacigaya/webskrap
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "webskrap"
|
|
7
|
-
version = "3.2.
|
|
7
|
+
version = "3.2.1"
|
|
8
8
|
description = "Async Python scraping on Chromium over its own CDP client, with coherent browser profiles and session controls."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -31,7 +31,6 @@ from collections.abc import AsyncIterator, Awaitable, Callable
|
|
|
31
31
|
from contextlib import AbstractAsyncContextManager, asynccontextmanager
|
|
32
32
|
from dataclasses import dataclass
|
|
33
33
|
from pathlib import Path
|
|
34
|
-
from random import SystemRandom
|
|
35
34
|
from typing import Any
|
|
36
35
|
from uuid import uuid4
|
|
37
36
|
|
|
@@ -43,8 +42,6 @@ from webskrap.display import VirtualDisplay
|
|
|
43
42
|
from webskrap.profiles import get_profile
|
|
44
43
|
|
|
45
44
|
REPORT = Path(".webskrap/reports/driver-parity.json")
|
|
46
|
-
# Cursor jitter only; system entropy keeps the scanner quiet, as in human.py.
|
|
47
|
-
_rng = SystemRandom()
|
|
48
45
|
|
|
49
46
|
# A page passes when no known challenge is on it and its title is not a
|
|
50
47
|
# challenge or block title.
|
|
@@ -120,8 +117,6 @@ TARGETS: dict[str, tuple[str, str]] = {
|
|
|
120
117
|
Evaluate = Callable[[str], Awaitable[Any]]
|
|
121
118
|
#: Writes a PNG of the page's viewport to the given path.
|
|
122
119
|
Screenshot = Callable[[Path], Awaitable[None]]
|
|
123
|
-
#: Sends one mouse event: ("move" | "down" | "up", x, y) in viewport CSS pixels.
|
|
124
|
-
Mouse = Callable[[str, float, float], Awaitable[None]]
|
|
125
120
|
|
|
126
121
|
|
|
127
122
|
@dataclass
|
|
@@ -130,51 +125,11 @@ class Page:
|
|
|
130
125
|
|
|
131
126
|
evaluate: Evaluate
|
|
132
127
|
screenshot: Screenshot
|
|
133
|
-
mouse: Mouse
|
|
134
128
|
#: Returns DataDome's response page kind from its iframe, or None when the
|
|
135
129
|
#: path cannot read that iframe.
|
|
136
130
|
datadome_kind: Callable[[], Awaitable[str | None]] | None = None
|
|
137
131
|
|
|
138
132
|
|
|
139
|
-
# Finds the Turnstile widget: the parent of its response input, or else the
|
|
140
|
-
# first widget-high box. The host can span the content width while the 300 px
|
|
141
|
-
# iframe sits at its left edge, so only the height is checked. Returns the
|
|
142
|
-
# host's viewport rectangle.
|
|
143
|
-
_TURNSTILE_BOX = """(() => {
|
|
144
|
-
const fits = (r) => r.width >= 250 && r.height >= 55 && r.height <= 80;
|
|
145
|
-
const input = document.querySelector('input[name="cf-turnstile-response"]');
|
|
146
|
-
const candidates = [input && input.parentElement, ...document.querySelectorAll('div')];
|
|
147
|
-
for (const element of candidates) {
|
|
148
|
-
if (!element) continue;
|
|
149
|
-
const r = element.getBoundingClientRect();
|
|
150
|
-
if (fits(r)) return { x: r.left, y: r.top, w: r.width, h: r.height };
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
})()"""
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
async def human_click(mouse: Mouse, x: float, y: float) -> None:
|
|
157
|
-
"""Move along an eased, jittered curve to (x, y), then press and release.
|
|
158
|
-
|
|
159
|
-
Both paths get the same cursor path through CDP input events, so the
|
|
160
|
-
comparison measures the browser setup, not the cursor model.
|
|
161
|
-
"""
|
|
162
|
-
start_x, start_y = x + _rng.uniform(250, 450), y + _rng.uniform(150, 300)
|
|
163
|
-
control_x, control_y = (start_x + x) / 2 + _rng.uniform(-80, 80), start_y - 60
|
|
164
|
-
steps = _rng.randint(22, 32)
|
|
165
|
-
for step in range(1, steps + 1):
|
|
166
|
-
t = step / steps
|
|
167
|
-
t = t * t * (3 - 2 * t) # ease in and out
|
|
168
|
-
px = (1 - t) ** 2 * start_x + 2 * (1 - t) * t * control_x + t * t * x
|
|
169
|
-
py = (1 - t) ** 2 * start_y + 2 * (1 - t) * t * control_y + t * t * y
|
|
170
|
-
await mouse("move", px + _rng.uniform(-0.8, 0.8), py + _rng.uniform(-0.8, 0.8))
|
|
171
|
-
await asyncio.sleep(_rng.uniform(0.008, 0.022))
|
|
172
|
-
await asyncio.sleep(_rng.uniform(0.12, 0.3))
|
|
173
|
-
await mouse("down", x, y)
|
|
174
|
-
await asyncio.sleep(_rng.uniform(0.06, 0.12))
|
|
175
|
-
await mouse("up", x, y)
|
|
176
|
-
|
|
177
|
-
|
|
178
133
|
def _config(mode: str) -> SessionConfig:
|
|
179
134
|
return SessionConfig(
|
|
180
135
|
channel="chromium",
|
|
@@ -189,22 +144,6 @@ def _page(page: CDPPage) -> Page:
|
|
|
189
144
|
shot = await page.send("Page.captureScreenshot", {"format": "png"})
|
|
190
145
|
path.write_bytes(base64.b64decode(shot["data"]))
|
|
191
146
|
|
|
192
|
-
async def mouse(kind: str, x: float, y: float) -> None:
|
|
193
|
-
# A held left button reports buttons=1 until it is released.
|
|
194
|
-
event = {"move": "mouseMoved", "down": "mousePressed", "up": "mouseReleased"}[kind]
|
|
195
|
-
pressed = kind == "down"
|
|
196
|
-
await page.send(
|
|
197
|
-
"Input.dispatchMouseEvent",
|
|
198
|
-
{
|
|
199
|
-
"type": event,
|
|
200
|
-
"x": x,
|
|
201
|
-
"y": y,
|
|
202
|
-
"button": "none" if kind == "move" else "left",
|
|
203
|
-
"buttons": 1 if pressed else 0,
|
|
204
|
-
"clickCount": 0 if kind == "move" else 1,
|
|
205
|
-
},
|
|
206
|
-
)
|
|
207
|
-
|
|
208
147
|
# Isolated worlds: the page cannot see the checks, and they need no globals.
|
|
209
148
|
async def datadome_kind() -> str | None:
|
|
210
149
|
for frame in await cdp_dom.frames(page):
|
|
@@ -212,7 +151,7 @@ def _page(page: CDPPage) -> Page:
|
|
|
212
151
|
return await frame.page.evaluate(_DATADOME_KIND)
|
|
213
152
|
return None
|
|
214
153
|
|
|
215
|
-
return Page(page.evaluate, screenshot,
|
|
154
|
+
return Page(page.evaluate, screenshot, datadome_kind)
|
|
216
155
|
|
|
217
156
|
|
|
218
157
|
@asynccontextmanager
|
|
@@ -257,7 +196,7 @@ def _via_session() -> Callable[[str, str], AbstractAsyncContextManager[Page]]:
|
|
|
257
196
|
"""Run a target through a persistent session, as `webskrap browser` does.
|
|
258
197
|
|
|
259
198
|
Every call attaches anew, like each CLI command or MCP tool call. Sessions
|
|
260
|
-
run headless or headed; a virtual display
|
|
199
|
+
run headless or headed; a virtual display is not offered.
|
|
261
200
|
"""
|
|
262
201
|
|
|
263
202
|
@asynccontextmanager
|
|
@@ -281,10 +220,7 @@ def _via_session() -> Callable[[str, str], AbstractAsyncContextManager[Page]]:
|
|
|
281
220
|
async def screenshot(path: Path) -> None:
|
|
282
221
|
await act(lambda page: browser_session.screenshot(page, path, full_page=False))
|
|
283
222
|
|
|
284
|
-
|
|
285
|
-
raise NotImplementedError("--click is not offered with --via session")
|
|
286
|
-
|
|
287
|
-
yield Page(evaluate, screenshot, mouse)
|
|
223
|
+
yield Page(evaluate, screenshot)
|
|
288
224
|
finally:
|
|
289
225
|
browser_session.close_session(name, delete_data=True)
|
|
290
226
|
|
|
@@ -293,29 +229,6 @@ def _via_session() -> Callable[[str, str], AbstractAsyncContextManager[Page]]:
|
|
|
293
229
|
|
|
294
230
|
SESSION_DRIVERS = {"session": _via_session()}
|
|
295
231
|
|
|
296
|
-
# The widget box renders before the checkbox inside its iframe does.
|
|
297
|
-
WIDGET_SETTLE_S = 3.0
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
async def _click_turnstile(page: Page, shot: Path | None) -> bool:
|
|
301
|
-
"""Click the Turnstile checkbox once it shows; False while it is absent."""
|
|
302
|
-
box = None
|
|
303
|
-
with contextlib.suppress(Exception):
|
|
304
|
-
box = await page.evaluate(_TURNSTILE_BOX)
|
|
305
|
-
if not box:
|
|
306
|
-
await asyncio.sleep(1)
|
|
307
|
-
return False
|
|
308
|
-
await asyncio.sleep(WIDGET_SETTLE_S)
|
|
309
|
-
if shot is not None:
|
|
310
|
-
with contextlib.suppress(Exception):
|
|
311
|
-
shot.parent.mkdir(parents=True, exist_ok=True)
|
|
312
|
-
await page.screenshot(shot.with_name(f"{shot.stem}-before-click.png"))
|
|
313
|
-
# The checkbox sits near the widget's left edge, centered vertically.
|
|
314
|
-
x = box["x"] + 22 + _rng.uniform(-3, 3)
|
|
315
|
-
y = box["y"] + box["h"] / 2 + _rng.uniform(-3, 3)
|
|
316
|
-
await human_click(page.mouse, x, y)
|
|
317
|
-
return True
|
|
318
|
-
|
|
319
232
|
|
|
320
233
|
async def run_once(
|
|
321
234
|
driver: str,
|
|
@@ -323,7 +236,6 @@ async def run_once(
|
|
|
323
236
|
target: str,
|
|
324
237
|
wait_s: float,
|
|
325
238
|
shot: Path | None = None,
|
|
326
|
-
click: bool = False,
|
|
327
239
|
via: str = "launch",
|
|
328
240
|
) -> dict[str, Any]:
|
|
329
241
|
url, check = TARGETS[target]
|
|
@@ -332,7 +244,6 @@ async def run_once(
|
|
|
332
244
|
# A pass after a challenge means the challenge cleared; a pass without one
|
|
333
245
|
# means the target never challenged this run.
|
|
334
246
|
challenged = False
|
|
335
|
-
clicked = False
|
|
336
247
|
try:
|
|
337
248
|
drivers = SESSION_DRIVERS if via == "session" else DRIVERS
|
|
338
249
|
async with drivers[driver](url, mode) as page:
|
|
@@ -348,9 +259,6 @@ async def run_once(
|
|
|
348
259
|
challenged = challenged or state in ("challenge", "datadome", "captcha")
|
|
349
260
|
if state == "passed":
|
|
350
261
|
break
|
|
351
|
-
if click and not clicked and state == "challenge":
|
|
352
|
-
clicked = await _click_turnstile(page, shot)
|
|
353
|
-
continue
|
|
354
262
|
if state in _SETTLING and time.monotonic() - started >= SETTLE_S:
|
|
355
263
|
break
|
|
356
264
|
await asyncio.sleep(1)
|
|
@@ -368,7 +276,6 @@ async def run_once(
|
|
|
368
276
|
"target": target,
|
|
369
277
|
"seconds": round(time.monotonic() - started, 1),
|
|
370
278
|
"challenged": challenged,
|
|
371
|
-
"clicked": clicked,
|
|
372
279
|
**verdict,
|
|
373
280
|
}
|
|
374
281
|
|
|
@@ -390,11 +297,6 @@ async def main() -> None:
|
|
|
390
297
|
type=Path,
|
|
391
298
|
help="Write a PNG of each run's last state to this directory.",
|
|
392
299
|
)
|
|
393
|
-
parser.add_argument(
|
|
394
|
-
"--click",
|
|
395
|
-
action="store_true",
|
|
396
|
-
help="Click a Cloudflare Turnstile checkbox when a challenge shows it.",
|
|
397
|
-
)
|
|
398
300
|
parser.add_argument(
|
|
399
301
|
"--via",
|
|
400
302
|
choices=("launch", "session"),
|
|
@@ -402,8 +304,8 @@ async def main() -> None:
|
|
|
402
304
|
help="launch a browser per run, or go through a persistent session.",
|
|
403
305
|
)
|
|
404
306
|
args = parser.parse_args()
|
|
405
|
-
if args.via == "session" and
|
|
406
|
-
parser.error("--via session runs headless or headed,
|
|
307
|
+
if args.via == "session" and "virtual-display" in (args.mode or []):
|
|
308
|
+
parser.error("--via session runs headless or headed, not on a virtual display")
|
|
407
309
|
modes = args.mode or (
|
|
408
310
|
["headless"] if args.via == "session" else ["headless", "virtual-display"]
|
|
409
311
|
)
|
|
@@ -429,16 +331,13 @@ async def main() -> None:
|
|
|
429
331
|
if args.screenshots
|
|
430
332
|
else None
|
|
431
333
|
)
|
|
432
|
-
result = await run_once(
|
|
433
|
-
driver, mode, target, args.wait, shot, click=args.click, via=args.via
|
|
434
|
-
)
|
|
334
|
+
result = await run_once(driver, mode, target, args.wait, shot, via=args.via)
|
|
435
335
|
results.append(result)
|
|
436
336
|
cleared = result["challenged"] and result["state"] == "passed"
|
|
437
337
|
print(
|
|
438
338
|
f"{target:13} {mode:15} {driver:10} {result['state']:9} "
|
|
439
339
|
f"{result['seconds']:5}s {result['detail']}"
|
|
440
|
-
f"{' (after challenge)' if cleared else ''}"
|
|
441
|
-
f"{' [clicked]' if result['clicked'] else ''}",
|
|
340
|
+
f"{' (after challenge)' if cleared else ''}",
|
|
442
341
|
flush=True,
|
|
443
342
|
)
|
|
444
343
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|