phantomwright 0.1.2__tar.gz → 0.1.3__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.
- {phantomwright-0.1.2 → phantomwright-0.1.3}/PKG-INFO +1 -1
- phantomwright-0.1.3/phantomwright/_repo_version.py +1 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/solver.py +13 -44
- {phantomwright-0.1.2 → phantomwright-0.1.3}/pyproject.toml +1 -1
- phantomwright-0.1.2/phantomwright/_repo_version.py +0 -1
- {phantomwright-0.1.2 → phantomwright-0.1.3}/.gitignore +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/LICENSE +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/README.md +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/_impl/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/_impl/_core_debug_patch.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/_impl/_evaluate_patch.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/_impl/_inconsistency_patch.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/async_api/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/scripts/observer.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/scripts/shadow_root.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/build_js.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/consts.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/detection.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/dom_helpers.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/shadow_root.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/py.typed +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.app.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.csi.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.hairline.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.load.times.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.runtime.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/error.prototype.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/iframe.contentWindow.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/media.codecs.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.hardwareConcurrency.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.languages.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.permissions.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.platform.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.plugins.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.userAgent.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.vendor.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/webgl.vendor.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/generate.magic.arrays.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/utils.js +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/stealth.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/sync_api/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/README.md +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/__init__.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/async_basic.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/async_simulator.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/script.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/sync_basic.py +0 -0
- {phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/user_simulator/sync_simulator.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: phantomwright
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Bridging playwright-core patch + extending playwright API for stealth injection & user simulation
|
|
5
5
|
Project-URL: homepage, https://github.com/ai-microsoft/phantom-wright
|
|
6
6
|
Project-URL: changelog, https://github.com/ai-microsoft/phantom-wright/blob/main/CHANGELOG.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = 'v0.1.3'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
3
|
import time
|
|
4
|
-
from typing import Callable, Optional
|
|
4
|
+
from typing import Callable, Optional
|
|
5
5
|
|
|
6
|
-
from phantomwright.async_api import Page,
|
|
6
|
+
from phantomwright.async_api import Page, BrowserContext
|
|
7
7
|
|
|
8
8
|
from .utils.consts import ChallengeType
|
|
9
9
|
from .utils.detection import (
|
|
@@ -46,7 +46,7 @@ class CloudflareSolverAsync:
|
|
|
46
46
|
|
|
47
47
|
def __init__(
|
|
48
48
|
self,
|
|
49
|
-
|
|
49
|
+
context: BrowserContext,
|
|
50
50
|
*,
|
|
51
51
|
max_attempts: int = 3,
|
|
52
52
|
attempt_delay: int = 5,
|
|
@@ -56,8 +56,7 @@ class CloudflareSolverAsync:
|
|
|
56
56
|
Initialize the Cloudflare solver.
|
|
57
57
|
|
|
58
58
|
Args:
|
|
59
|
-
|
|
60
|
-
If a Browser is provided, all its contexts will be monitored.
|
|
59
|
+
context: Playwright BrowserContext to monitor for challenges.
|
|
61
60
|
max_attempts: Maximum number of solve attempts per challenge.
|
|
62
61
|
attempt_delay: Delay in seconds between retry attempts.
|
|
63
62
|
log_callback: Optional callback function that receives a JSON string
|
|
@@ -71,9 +70,7 @@ class CloudflareSolverAsync:
|
|
|
71
70
|
- error: Error message if failed, None otherwise
|
|
72
71
|
- timestamp: Unix timestamp of the event
|
|
73
72
|
"""
|
|
74
|
-
self.
|
|
75
|
-
self._browser: Optional[Browser] = context_or_browser if self._is_browser else None
|
|
76
|
-
self._context: Optional[BrowserContext] = None if self._is_browser else context_or_browser
|
|
73
|
+
self.context = context
|
|
77
74
|
self.max_attempts = max_attempts
|
|
78
75
|
self.attempt_delay = attempt_delay
|
|
79
76
|
self.log = log_callback
|
|
@@ -237,48 +234,20 @@ class CloudflareSolverAsync:
|
|
|
237
234
|
await page.expose_function("__cf_callback", self._make_on_cf_detected(page))
|
|
238
235
|
page.on("load", lambda: asyncio.create_task(self._rebind(page)))
|
|
239
236
|
|
|
240
|
-
def _setup_context(self, context: BrowserContext) -> None:
|
|
241
|
-
"""Set up page monitoring for a single context."""
|
|
242
|
-
context.on(
|
|
243
|
-
"page",
|
|
244
|
-
lambda p: asyncio.create_task(self._setup_page(p)),
|
|
245
|
-
)
|
|
246
|
-
|
|
247
237
|
# ---------------- public api ----------------
|
|
248
238
|
def start(self) -> None:
|
|
249
239
|
"""
|
|
250
|
-
Start monitoring the browser
|
|
240
|
+
Start monitoring the browser context for Cloudflare challenges.
|
|
251
241
|
|
|
252
|
-
This method registers event listeners
|
|
253
|
-
Cloudflare challenges on any new page. Call this once
|
|
254
|
-
the solver instance.
|
|
255
|
-
|
|
256
|
-
If initialized with a Browser, monitors all existing and new contexts.
|
|
257
|
-
If initialized with a BrowserContext, monitors only that context.
|
|
242
|
+
This method registers event listeners on the context to automatically
|
|
243
|
+
detect and solve Cloudflare challenges on any new page. Call this once
|
|
244
|
+
after creating the solver instance.
|
|
258
245
|
|
|
259
246
|
Note:
|
|
260
247
|
This method is synchronous but sets up async handlers internally.
|
|
261
248
|
Challenges will be solved automatically in the background.
|
|
262
249
|
"""
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
def _check_and_setup_contexts():
|
|
268
|
-
for context in self._browser.contexts:
|
|
269
|
-
if context not in self._monitored_contexts:
|
|
270
|
-
self._monitored_contexts.add(context)
|
|
271
|
-
self._setup_context(context)
|
|
272
|
-
|
|
273
|
-
# Monitor all existing contexts
|
|
274
|
-
_check_and_setup_contexts()
|
|
275
|
-
|
|
276
|
-
# Start a background task to periodically check for new contexts
|
|
277
|
-
async def _monitor_contexts():
|
|
278
|
-
while self._browser.is_connected():
|
|
279
|
-
_check_and_setup_contexts()
|
|
280
|
-
await asyncio.sleep(0.1) # Check every 100ms for new contexts
|
|
281
|
-
|
|
282
|
-
self._monitor_task = asyncio.create_task(_monitor_contexts())
|
|
283
|
-
else:
|
|
284
|
-
self._setup_context(self._context)
|
|
250
|
+
self.context.on(
|
|
251
|
+
"page",
|
|
252
|
+
lambda p: asyncio.create_task(self._setup_page(p)),
|
|
253
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = 'v0.1.2'
|
|
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
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/scripts/observer.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/scripts/shadow_root.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/build_js.py
RENAMED
|
File without changes
|
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/detection.py
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/dom_helpers.py
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/captcha/cloudfare/utils/shadow_root.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.hairline.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.load.times.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/chrome.runtime.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/error.prototype.js
RENAMED
|
File without changes
|
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/media.codecs.js
RENAMED
|
File without changes
|
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.languages.js
RENAMED
|
File without changes
|
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.platform.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.plugins.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.userAgent.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/navigator.vendor.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/evasions/webgl.vendor.js
RENAMED
|
File without changes
|
{phantomwright-0.1.2 → phantomwright-0.1.3}/phantomwright/stealth/js/generate.magic.arrays.js
RENAMED
|
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
|