|
| 1 | +# Humanizer |
| 2 | + |
| 3 | +WebSkrap's humanizer is the `human_click` session helper. It waits for a visible |
| 4 | +target, scrolls it into view, moves the mouse along a curved eased path, and then |
| 5 | +clicks near the target center instead of calling Playwright's direct |
| 6 | +`page.click`. |
| 7 | + |
| 8 | +```python |
| 9 | +async with WebSkrapClient() as client: |
| 10 | + session = await client.session("default") |
| 11 | + page = await session.context.new_page() |
| 12 | + await page.goto("https://example.com", wait_until="domcontentloaded") |
| 13 | + await session.human_click(page, "button[type='submit']") |
| 14 | +``` |
| 15 | + |
| 16 | +Use it when a normal page interaction should look closer to a manual browser |
| 17 | +click. It is useful for flows with hover-sensitive controls, scroll-dependent |
| 18 | +layouts, or simple behavioral checks that treat instant coordinate jumps as |
| 19 | +synthetic. |
| 20 | + |
| 21 | +## Direct click fallback |
| 22 | + |
| 23 | +Pass `human=False` to keep the same call shape while delegating to Playwright's |
| 24 | +click implementation. |
| 25 | + |
| 26 | +```python |
| 27 | +await session.human_click(page, "button[type='submit']", human=False, timeout=5_000) |
| 28 | +``` |
| 29 | + |
| 30 | +## Click options |
| 31 | + |
| 32 | +`human_click` accepts normal Playwright click options including `button`, |
| 33 | +`click_count`, `delay`, `modifiers`, `position`, `strict`, `timeout`, and |
| 34 | +`trial`. |
| 35 | + |
| 36 | +```python |
| 37 | +await session.human_click( |
| 38 | + page, |
| 39 | + "button[type='submit']", |
| 40 | + strict=True, |
| 41 | + timeout=10_000, |
| 42 | + modifiers=["Shift"], |
| 43 | +) |
| 44 | +``` |
| 45 | + |
| 46 | +## Boundaries |
| 47 | + |
| 48 | +Humanized clicks do not solve CAPTCHAs, bypass login walls, evade access |
| 49 | +controls, or grant permission to scrape restricted targets. Use them only on |
| 50 | +sites and workflows you are allowed to access. |
0 commit comments