capiumbrowser 1.3.1__tar.gz → 1.3.2__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.
- {capiumbrowser-1.3.1/capiumbrowser.egg-info → capiumbrowser-1.3.2}/PKG-INFO +1 -1
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/_version.py +1 -1
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/channels.json +7 -7
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/human/__init__.py +5 -3
- capiumbrowser-1.3.2/capiumbrowser/human/behavior.py +180 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2/capiumbrowser.egg-info}/PKG-INFO +1 -1
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/pyproject.toml +1 -1
- capiumbrowser-1.3.1/capiumbrowser/human/behavior.py +0 -104
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/LICENSE +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/MANIFEST.in +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/README.md +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/__init__.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/__main__.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/_driver.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/android-phones.json +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/browser-brands.json +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/browser.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/browser_async.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/config.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/desktop.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/errors.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/ios-phones.json +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/licensing/__init__.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/licensing/client.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/licensing/download.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/licensing/readiness.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/mobile.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/network/__init__.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser/network/proxy.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/SOURCES.txt +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/dependency_links.txt +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/entry_points.txt +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/requires.txt +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/capiumbrowser.egg-info/top_level.txt +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/setup.cfg +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_channels_manifest.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_config_args.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_desktop_brands.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_download_contract.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_geoip_flags.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_ios_profiles.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_launch_viewport.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_license_readiness.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_mobile_profiles.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_proxy.py +0 -0
- {capiumbrowser-1.3.1 → capiumbrowser-1.3.2}/tests/test_version_tables_consistent.py +0 -0
|
@@ -17,7 +17,7 @@ import json
|
|
|
17
17
|
import os
|
|
18
18
|
import platform as _platform
|
|
19
19
|
|
|
20
|
-
__version__ = "1.3.
|
|
20
|
+
__version__ = "1.3.2"
|
|
21
21
|
|
|
22
22
|
# Used only if channels.json can't be read (corrupt/removed install). ensure_binary() raises a
|
|
23
23
|
# clear error long before the "unsupported platform" case matters; this keeps lookups total.
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_comment": "SINGLE SOURCE OF TRUTH for the current stable Capium browser build per OS/arch. Each OS reaches stable independently -- edit one entry without touching the others. This file ships inside the wheel (the SDK reads it to pick each host's stable build) AND is published to the download server by the release pipeline. `version` is the reported Chromium version (what the browser reports to the customer, names the R2 folder); `engine_version` is the actual built Chromium engine (box_package verifies the binary against it) -- it differs from `version` when a platform reports a spoofed patch (Windows/macOS report .48 on the .47 engine). `revision` is our packaging counter -- the served R2 folder is chromium-v<version>.<revision>/, ALWAYS dotted-suffixed starting at 1. A Chromium version bump resets revision to 1. `published: false` means the tag is declared but no artifact exists yet.",
|
|
3
3
|
"schema": 1,
|
|
4
|
-
"updated": "2026-10-
|
|
4
|
+
"updated": "2026-10-27",
|
|
5
5
|
"channels": {
|
|
6
6
|
"stable": {
|
|
7
7
|
"windows-x64": {
|
|
8
8
|
"version": "156.0.8078.48",
|
|
9
9
|
"engine_version": "156.0.8078.47",
|
|
10
|
-
"revision":
|
|
11
|
-
"sha256": "
|
|
10
|
+
"revision": 3,
|
|
11
|
+
"sha256": "ad26bd1e62343ec741b3cd2ce8f73e00dfc6c25564654bfba828efb29a372a69",
|
|
12
12
|
"published": true,
|
|
13
13
|
"license_status_protocol": 1
|
|
14
14
|
},
|
|
15
15
|
"macos-arm64": {
|
|
16
16
|
"version": "156.0.8078.48",
|
|
17
17
|
"engine_version": "156.0.8078.47",
|
|
18
|
-
"revision":
|
|
19
|
-
"sha256": "
|
|
18
|
+
"revision": 3,
|
|
19
|
+
"sha256": "ce85cf43d57ff5ab4d35416b874d50560705c07e296c0b41b5cb78ee0d6f6eda",
|
|
20
20
|
"published": true,
|
|
21
21
|
"license_status_protocol": 1
|
|
22
22
|
},
|
|
23
23
|
"linux-x64": {
|
|
24
24
|
"version": "156.0.8078.47",
|
|
25
25
|
"engine_version": "156.0.8078.47",
|
|
26
|
-
"revision":
|
|
27
|
-
"sha256": "
|
|
26
|
+
"revision": 3,
|
|
27
|
+
"sha256": "0ecad673f91b68b251e1185d88df6c46da35be592c46f45f015e189cd57b3152",
|
|
28
28
|
"published": true,
|
|
29
29
|
"license_status_protocol": 1
|
|
30
30
|
},
|
|
@@ -16,11 +16,12 @@ Two ways to use it:
|
|
|
16
16
|
page.human_click("#login"); page.human_type("#user", "alice")
|
|
17
17
|
"""
|
|
18
18
|
from . import behavior
|
|
19
|
-
from .behavior import move, click, type_text, scroll, dwell
|
|
19
|
+
from .behavior import move, click, type_text, scroll, dwell, hold
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def humanize(target, preset="default"):
|
|
23
|
-
"""Attach page.human_move / human_click / human_type / human_scroll / human_dwell
|
|
23
|
+
"""Attach page.human_move / human_click / human_type / human_scroll / human_dwell /
|
|
24
|
+
human_hold.
|
|
24
25
|
|
|
25
26
|
target may be a Page or a BrowserContext (all current + future pages are patched).
|
|
26
27
|
Returns target (chainable). Does NOT override page.click/type so existing code is safe;
|
|
@@ -34,6 +35,7 @@ def humanize(target, preset="default"):
|
|
|
34
35
|
page.human_click = lambda sel, p=preset: click(page, sel, p)
|
|
35
36
|
page.human_type = lambda sel, text, p=preset: type_text(page, sel, text, p)
|
|
36
37
|
page.human_scroll = lambda dy, p=preset: scroll(page, dy, p)
|
|
38
|
+
page.human_hold = lambda sel, seconds, p=preset: hold(page, sel, seconds, p)
|
|
37
39
|
page.human_dwell = dwell
|
|
38
40
|
|
|
39
41
|
# context: patch existing + hook new pages
|
|
@@ -46,4 +48,4 @@ def humanize(target, preset="default"):
|
|
|
46
48
|
return target
|
|
47
49
|
|
|
48
50
|
|
|
49
|
-
__all__ = ["humanize", "move", "click", "type_text", "scroll", "dwell", "behavior"]
|
|
51
|
+
__all__ = ["humanize", "move", "click", "type_text", "scroll", "dwell", "hold", "behavior"]
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""
|
|
2
|
+
capium.human.behavior -- realistic mouse / typing / scroll / press-and-hold for Playwright pages.
|
|
3
|
+
|
|
4
|
+
Anti-bot systems increasingly score *behavior*, and the modern ones (PX/HUMAN press-and-hold,
|
|
5
|
+
DataDome slider) score pointer BIOMETRICS, not just "did a cursor arrive": velocity profile
|
|
6
|
+
(humans accelerate then decelerate into the target -- Fitts's law -- never constant speed),
|
|
7
|
+
orthogonal micro-jitter along the path, overshoot-and-correct on long moves, and physiological
|
|
8
|
+
tremor during a sustained press (a hand cannot hold a mouse perfectly still; a rock-still
|
|
9
|
+
multi-second hold is a machine signature). These helpers produce all of that with pure
|
|
10
|
+
Playwright input (page.mouse / page.keyboard) -- no CDP tricks, so the event stream stays
|
|
11
|
+
consistent with the stealth binary (isTrusted=true, normal coalescing).
|
|
12
|
+
|
|
13
|
+
Presets tune the timing:
|
|
14
|
+
"default" -> natural human pace
|
|
15
|
+
"careful" -> slower, more deliberate (harder to flag, but slower runs)
|
|
16
|
+
"""
|
|
17
|
+
import math
|
|
18
|
+
import random
|
|
19
|
+
import time
|
|
20
|
+
|
|
21
|
+
PRESETS = {
|
|
22
|
+
"default": {"move_steps": (18, 34), "step_ms": (6, 16), "key_ms": (45, 130),
|
|
23
|
+
"click_pause_ms": (40, 140), "scroll_step": (90, 220), "scroll_ms": (30, 90),
|
|
24
|
+
"tremor_px": 1.1, "tremor_ms": (35, 110)},
|
|
25
|
+
"careful": {"move_steps": (30, 55), "step_ms": (12, 28), "key_ms": (80, 220),
|
|
26
|
+
"click_pause_ms": (120, 320), "scroll_step": (50, 130), "scroll_ms": (60, 150),
|
|
27
|
+
"tremor_px": 0.9, "tremor_ms": (50, 140)},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _cfg(preset):
|
|
32
|
+
return PRESETS.get(preset, PRESETS["default"])
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _rand_ms(rng):
|
|
36
|
+
return random.uniform(rng[0], rng[1]) / 1000.0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _pos(page):
|
|
40
|
+
return getattr(page, "_capium_mouse", (random.randint(2, 60), random.randint(2, 60)))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _velocity_warp(t):
|
|
44
|
+
# Smoothstep time-warp: sampling the curve at these t values yields a bell-shaped
|
|
45
|
+
# velocity profile -- slow start, fast middle, decelerating arrival (Fitts-like) --
|
|
46
|
+
# instead of the constant speed that uniform sampling produces.
|
|
47
|
+
return t * t * (3.0 - 2.0 * t)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _bezier(x0, y0, x1, y1, steps):
|
|
51
|
+
# Two random control points -> a curved, non-linear path; velocity-warped sampling +
|
|
52
|
+
# orthogonal micro-jitter (largest mid-path, vanishing at the endpoints).
|
|
53
|
+
cx1 = x0 + (x1 - x0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
54
|
+
cy1 = y0 + (y1 - y0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
55
|
+
cx2 = x0 + (x1 - x0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
56
|
+
cy2 = y0 + (y1 - y0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
57
|
+
dx, dy = x1 - x0, y1 - y0
|
|
58
|
+
dist = math.hypot(dx, dy) or 1.0
|
|
59
|
+
nx, ny = -dy / dist, dx / dist # unit normal to the gross direction
|
|
60
|
+
jmax = min(1.6, dist / 120.0) # short hops barely wobble
|
|
61
|
+
pts = []
|
|
62
|
+
for i in range(1, steps + 1):
|
|
63
|
+
lt = i / steps
|
|
64
|
+
t = _velocity_warp(lt)
|
|
65
|
+
mt = 1 - t
|
|
66
|
+
x = mt**3 * x0 + 3 * mt**2 * t * cx1 + 3 * mt * t**2 * cx2 + t**3 * x1
|
|
67
|
+
y = mt**3 * y0 + 3 * mt**2 * t * cy1 + 3 * mt * t**2 * cy2 + t**3 * y1
|
|
68
|
+
j = math.sin(math.pi * lt) * random.uniform(-jmax, jmax)
|
|
69
|
+
pts.append((x + nx * j, y + ny * j))
|
|
70
|
+
return pts
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _run_path(page, pts, c):
|
|
74
|
+
for (px, py) in pts:
|
|
75
|
+
page.mouse.move(px, py)
|
|
76
|
+
d = _rand_ms(c["step_ms"])
|
|
77
|
+
if random.random() < 0.02: # occasional motor hitch
|
|
78
|
+
d += random.uniform(0.03, 0.08)
|
|
79
|
+
time.sleep(d)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def move(page, x, y, preset="default"):
|
|
83
|
+
"""Move the cursor to (x, y) along a human-like curved path.
|
|
84
|
+
|
|
85
|
+
Long moves overshoot the target by a few pixels and correct -- the
|
|
86
|
+
characteristic human "land past it, pull back" arrival that biometric
|
|
87
|
+
scorers look for (its absence over many moves is a tell)."""
|
|
88
|
+
c = _cfg(preset)
|
|
89
|
+
x0, y0 = _pos(page)
|
|
90
|
+
dist = math.hypot(x - x0, y - y0)
|
|
91
|
+
steps = random.randint(*c["move_steps"])
|
|
92
|
+
if dist > 180 and random.random() < 0.6:
|
|
93
|
+
ux, uy = (x - x0) / dist, (y - y0) / dist
|
|
94
|
+
over = random.uniform(3, 14)
|
|
95
|
+
ox, oy = x + ux * over, y + uy * over
|
|
96
|
+
_run_path(page, _bezier(x0, y0, ox, oy, steps), c)
|
|
97
|
+
_run_path(page, _bezier(ox, oy, x, y, random.randint(4, 8)), c)
|
|
98
|
+
else:
|
|
99
|
+
_run_path(page, _bezier(x0, y0, x, y, steps), c)
|
|
100
|
+
page._capium_mouse = (x, y)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _resolve_point(page, target):
|
|
104
|
+
"""Target: a selector string, or an (x, y) tuple/list."""
|
|
105
|
+
if isinstance(target, (tuple, list)) and len(target) == 2:
|
|
106
|
+
return float(target[0]), float(target[1])
|
|
107
|
+
el = page.wait_for_selector(target, state="visible")
|
|
108
|
+
box = el.bounding_box()
|
|
109
|
+
return (box["x"] + box["width"] * random.uniform(0.3, 0.7),
|
|
110
|
+
box["y"] + box["height"] * random.uniform(0.3, 0.7))
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def click(page, selector, preset="default"):
|
|
114
|
+
"""Move to a random point inside `selector` and click with a natural pause."""
|
|
115
|
+
c = _cfg(preset)
|
|
116
|
+
tx, ty = _resolve_point(page, selector)
|
|
117
|
+
move(page, tx, ty, preset)
|
|
118
|
+
time.sleep(_rand_ms(c["click_pause_ms"]))
|
|
119
|
+
page.mouse.down()
|
|
120
|
+
time.sleep(random.uniform(0.03, 0.09))
|
|
121
|
+
page.mouse.up()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def hold(page, target, seconds, preset="default"):
|
|
125
|
+
"""Press-and-hold on `target` (selector or (x, y)) for ~`seconds`, with tremor.
|
|
126
|
+
|
|
127
|
+
Built for press-and-hold challenges (PX/HUMAN and similar), which measure the
|
|
128
|
+
pointer DURING the press: a real hand drifts and trembles ~1px around the
|
|
129
|
+
anchor the whole time, and releases slightly late. A hold with zero pointer
|
|
130
|
+
events between mousedown and mouseup reads as synthetic no matter how good
|
|
131
|
+
the approach path was. `seconds` should be the challenge's required duration;
|
|
132
|
+
a natural human release lag is added on top."""
|
|
133
|
+
c = _cfg(preset)
|
|
134
|
+
tx, ty = _resolve_point(page, target)
|
|
135
|
+
move(page, tx, ty, preset)
|
|
136
|
+
time.sleep(_rand_ms(c["click_pause_ms"]))
|
|
137
|
+
page.mouse.down()
|
|
138
|
+
amp = c["tremor_px"]
|
|
139
|
+
ax, ay = tx, ty # slow random-walk drift anchor
|
|
140
|
+
end = time.monotonic() + float(seconds) + random.uniform(0.15, 0.45)
|
|
141
|
+
while time.monotonic() < end:
|
|
142
|
+
time.sleep(_rand_ms(c["tremor_ms"]))
|
|
143
|
+
if random.random() < 0.7: # tremor tick: micro-move near the anchor
|
|
144
|
+
ax += random.uniform(-0.35, 0.35) # the anchor itself drifts a little
|
|
145
|
+
ay += random.uniform(-0.35, 0.35)
|
|
146
|
+
ax = min(tx + 3, max(tx - 3, ax))
|
|
147
|
+
ay = min(ty + 3, max(ty - 3, ay))
|
|
148
|
+
page.mouse.move(ax + random.gauss(0, amp * 0.5),
|
|
149
|
+
ay + random.gauss(0, amp * 0.5))
|
|
150
|
+
page.mouse.up()
|
|
151
|
+
page._capium_mouse = (ax, ay)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def type_text(page, selector, text, preset="default"):
|
|
155
|
+
"""Click the field, then type with per-key jitter (occasional longer pauses)."""
|
|
156
|
+
c = _cfg(preset)
|
|
157
|
+
click(page, selector, preset)
|
|
158
|
+
for ch in text:
|
|
159
|
+
page.keyboard.type(ch)
|
|
160
|
+
d = _rand_ms(c["key_ms"])
|
|
161
|
+
if random.random() < 0.06: # occasional think-pause
|
|
162
|
+
d += random.uniform(0.15, 0.5)
|
|
163
|
+
time.sleep(d)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def scroll(page, dy, preset="default"):
|
|
167
|
+
"""Scroll `dy` pixels (positive = down) in eased increments, not one jump."""
|
|
168
|
+
c = _cfg(preset)
|
|
169
|
+
remaining = dy
|
|
170
|
+
direction = 1 if dy >= 0 else -1
|
|
171
|
+
while abs(remaining) > 1:
|
|
172
|
+
step = min(abs(remaining), random.uniform(*c["scroll_step"])) * direction
|
|
173
|
+
page.mouse.wheel(0, step)
|
|
174
|
+
remaining -= step
|
|
175
|
+
time.sleep(_rand_ms(c["scroll_ms"]))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def dwell(lo=0.4, hi=1.8):
|
|
179
|
+
"""Idle a human-plausible moment (reading/hesitating)."""
|
|
180
|
+
time.sleep(random.uniform(lo, hi))
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
capium.human.behavior -- realistic mouse / typing / scroll for Playwright pages.
|
|
3
|
-
|
|
4
|
-
Anti-bot systems increasingly score *behavior*: instant teleport-clicks, zero-jitter typing
|
|
5
|
-
and single-delta scrolls are bot tells. These helpers move the cursor along a bezier path with
|
|
6
|
-
variable speed, type with per-key jitter, and scroll in eased increments. Pure Playwright input
|
|
7
|
-
(page.mouse / page.keyboard) -- no CDP tricks, so it stays consistent with the stealth binary.
|
|
8
|
-
|
|
9
|
-
Presets tune the timing:
|
|
10
|
-
"default" -> natural human pace
|
|
11
|
-
"careful" -> slower, more deliberate (harder to flag, but slower runs)
|
|
12
|
-
"""
|
|
13
|
-
import math
|
|
14
|
-
import random
|
|
15
|
-
import time
|
|
16
|
-
|
|
17
|
-
PRESETS = {
|
|
18
|
-
"default": {"move_steps": (18, 34), "step_ms": (6, 16), "key_ms": (45, 130),
|
|
19
|
-
"click_pause_ms": (40, 140), "scroll_step": (90, 220), "scroll_ms": (30, 90)},
|
|
20
|
-
"careful": {"move_steps": (30, 55), "step_ms": (12, 28), "key_ms": (80, 220),
|
|
21
|
-
"click_pause_ms": (120, 320), "scroll_step": (50, 130), "scroll_ms": (60, 150)},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _cfg(preset):
|
|
26
|
-
return PRESETS.get(preset, PRESETS["default"])
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def _rand_ms(rng):
|
|
30
|
-
return random.uniform(rng[0], rng[1]) / 1000.0
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def _pos(page):
|
|
34
|
-
return getattr(page, "_capium_mouse", (random.randint(2, 60), random.randint(2, 60)))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _bezier(x0, y0, x1, y1, steps):
|
|
38
|
-
# two random control points -> a curved, non-linear path
|
|
39
|
-
cx1 = x0 + (x1 - x0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
40
|
-
cy1 = y0 + (y1 - y0) * random.uniform(0.2, 0.45) + random.uniform(-40, 40)
|
|
41
|
-
cx2 = x0 + (x1 - x0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
42
|
-
cy2 = y0 + (y1 - y0) * random.uniform(0.55, 0.8) + random.uniform(-40, 40)
|
|
43
|
-
pts = []
|
|
44
|
-
for i in range(1, steps + 1):
|
|
45
|
-
t = i / steps
|
|
46
|
-
mt = 1 - t
|
|
47
|
-
x = mt**3 * x0 + 3 * mt**2 * t * cx1 + 3 * mt * t**2 * cx2 + t**3 * x1
|
|
48
|
-
y = mt**3 * y0 + 3 * mt**2 * t * cy1 + 3 * mt * t**2 * cy2 + t**3 * y1
|
|
49
|
-
pts.append((x, y))
|
|
50
|
-
return pts
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def move(page, x, y, preset="default"):
|
|
54
|
-
"""Move the cursor to (x, y) along a human-like curved path."""
|
|
55
|
-
c = _cfg(preset)
|
|
56
|
-
x0, y0 = _pos(page)
|
|
57
|
-
steps = random.randint(*c["move_steps"])
|
|
58
|
-
for (px, py) in _bezier(x0, y0, x, y, steps):
|
|
59
|
-
page.mouse.move(px, py)
|
|
60
|
-
time.sleep(_rand_ms(c["step_ms"]))
|
|
61
|
-
page._capium_mouse = (x, y)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def click(page, selector, preset="default"):
|
|
65
|
-
"""Move to a random point inside `selector` and click with a natural pause."""
|
|
66
|
-
c = _cfg(preset)
|
|
67
|
-
el = page.wait_for_selector(selector, state="visible")
|
|
68
|
-
box = el.bounding_box()
|
|
69
|
-
tx = box["x"] + box["width"] * random.uniform(0.3, 0.7)
|
|
70
|
-
ty = box["y"] + box["height"] * random.uniform(0.3, 0.7)
|
|
71
|
-
move(page, tx, ty, preset)
|
|
72
|
-
time.sleep(_rand_ms(c["click_pause_ms"]))
|
|
73
|
-
page.mouse.down()
|
|
74
|
-
time.sleep(random.uniform(0.03, 0.09))
|
|
75
|
-
page.mouse.up()
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def type_text(page, selector, text, preset="default"):
|
|
79
|
-
"""Click the field, then type with per-key jitter (occasional longer pauses)."""
|
|
80
|
-
c = _cfg(preset)
|
|
81
|
-
click(page, selector, preset)
|
|
82
|
-
for ch in text:
|
|
83
|
-
page.keyboard.type(ch)
|
|
84
|
-
d = _rand_ms(c["key_ms"])
|
|
85
|
-
if random.random() < 0.06: # occasional think-pause
|
|
86
|
-
d += random.uniform(0.15, 0.5)
|
|
87
|
-
time.sleep(d)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def scroll(page, dy, preset="default"):
|
|
91
|
-
"""Scroll `dy` pixels (positive = down) in eased increments, not one jump."""
|
|
92
|
-
c = _cfg(preset)
|
|
93
|
-
remaining = dy
|
|
94
|
-
direction = 1 if dy >= 0 else -1
|
|
95
|
-
while abs(remaining) > 1:
|
|
96
|
-
step = min(abs(remaining), random.uniform(*c["scroll_step"])) * direction
|
|
97
|
-
page.mouse.wheel(0, step)
|
|
98
|
-
remaining -= step
|
|
99
|
-
time.sleep(_rand_ms(c["scroll_ms"]))
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def dwell(lo=0.4, hi=1.8):
|
|
103
|
-
"""Idle a human-plausible moment (reading/hesitating)."""
|
|
104
|
-
time.sleep(random.uniform(lo, hi))
|
|
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
|