scrapely-python 0.1.24__py3-none-any.whl → 0.1.26__py3-none-any.whl
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.
- scrapely/__init__.py +1 -1
- scrapely/actor.py +24 -0
- scrapely/solver.py +6 -5
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/METADATA +1 -1
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/RECORD +10 -10
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/WHEEL +0 -0
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/licenses/LICENSE +0 -0
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/licenses/LICENSE-APACHE +0 -0
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/licenses/NOTICE +0 -0
- {scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/top_level.txt +0 -0
scrapely/__init__.py
CHANGED
scrapely/actor.py
CHANGED
|
@@ -360,6 +360,7 @@ class Actor(metaclass=_ActorMeta):
|
|
|
360
360
|
|
|
361
361
|
@classmethod
|
|
362
362
|
async def init(cls, options: Optional[InitOptions] = None) -> None:
|
|
363
|
+
cls._main_loop = asyncio.get_running_loop() # for debug_capture_sync from worker threads
|
|
363
364
|
if cls._initialized:
|
|
364
365
|
return
|
|
365
366
|
|
|
@@ -934,6 +935,29 @@ class Actor(metaclass=_ActorMeta):
|
|
|
934
935
|
import hashlib
|
|
935
936
|
return 'DEBUG_CAPTURE_' + hashlib.sha1(str(key).strip().encode('utf-8')).hexdigest()[:24]
|
|
936
937
|
|
|
938
|
+
_main_loop: Optional[asyncio.AbstractEventLoop] = None
|
|
939
|
+
|
|
940
|
+
@classmethod
|
|
941
|
+
def debug_capture_sync(cls, key: str, payload: Any) -> None:
|
|
942
|
+
"""debug_capture for synchronous code (also from worker threads, e.g. asyncio.to_thread).
|
|
943
|
+
Does nothing unless the platform enabled capture for this run."""
|
|
944
|
+
if os.environ.get('SCRAPELY_DEBUG_CAPTURE') != '1' or not key:
|
|
945
|
+
return
|
|
946
|
+
loop = cls._main_loop
|
|
947
|
+
if loop is None or loop.is_closed():
|
|
948
|
+
return
|
|
949
|
+
try:
|
|
950
|
+
try:
|
|
951
|
+
running = asyncio.get_running_loop()
|
|
952
|
+
except RuntimeError:
|
|
953
|
+
running = None
|
|
954
|
+
if running is loop:
|
|
955
|
+
loop.create_task(cls.debug_capture(key, payload))
|
|
956
|
+
else:
|
|
957
|
+
asyncio.run_coroutine_threadsafe(cls.debug_capture(key, payload), loop).result(timeout=15)
|
|
958
|
+
except Exception as err: # never break the run
|
|
959
|
+
logging.getLogger('scrapely').debug('debug_capture_sync failed: %s', err)
|
|
960
|
+
|
|
937
961
|
@classmethod
|
|
938
962
|
async def debug_capture(cls, key: str, payload: Any) -> None:
|
|
939
963
|
"""Save the raw source payload (API JSON or HTML) an item was extracted from, keyed by
|
scrapely/solver.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Anti-bot solver helpers for Scrapely Actors.
|
|
2
2
|
|
|
3
|
-
The platform runs the challenge solver
|
|
3
|
+
The platform runs the challenge solver behind
|
|
4
4
|
``/v2/solver``. Actors never hold a solver key: the platform injects
|
|
5
5
|
``SCRAPELY_SOLVER_URL`` and ``SCRAPELY_SOLVER_API_KEY`` (the run's own token)
|
|
6
6
|
into runs of Actors that may use it.
|
|
@@ -88,7 +88,7 @@ DEGRADED_STATUS_MESSAGE = "Site protection temporarily unavailable, results may
|
|
|
88
88
|
# Codes the platform answers with when a vendor cannot be solved right now.
|
|
89
89
|
UNAVAILABLE_CODES = ("vendor_degraded", "vendor_down", "provider_unavailable", "vendor_unsupported", "solver_not_enabled")
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
_COMPAT_SUFFIXES = ("/compat/v1", "/compat/xhrdev")
|
|
92
92
|
_STATUS_TTL_SECS = 15.0
|
|
93
93
|
_MAX_BODY = 4 * 1024 * 1024
|
|
94
94
|
|
|
@@ -118,9 +118,10 @@ def _gateway() -> tuple[str, str] | None:
|
|
|
118
118
|
if env is None:
|
|
119
119
|
return None
|
|
120
120
|
url, key = env
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
for suffix in _COMPAT_SUFFIXES:
|
|
122
|
+
if url.endswith(suffix):
|
|
123
|
+
return url[: -len(suffix)], key
|
|
124
|
+
return None
|
|
124
125
|
|
|
125
126
|
|
|
126
127
|
# ─── errors ──────────────────────────────────────────────────────────────────
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
scrapely/__init__.py,sha256=
|
|
1
|
+
scrapely/__init__.py,sha256=z-CyEPAlCd07V32Wnv8bNeSubMhXAuoejvSW7-XG4co,9661
|
|
2
2
|
scrapely/_browser_locations.py,sha256=8QVVnkms2bDn3_LDYgYDR59MvFx8757l_JYnZ7xb3oI,145269
|
|
3
|
-
scrapely/actor.py,sha256=
|
|
3
|
+
scrapely/actor.py,sha256=1SBHZYBRLmU4k_erjKL7yRfP0EgR7ZKXefAK8wWKRz0,88004
|
|
4
4
|
scrapely/browser_configuration.py,sha256=jAZapNSHLFW05B96df4wNBtcyiiU9DA3ml0yTL1FwfA,5770
|
|
5
5
|
scrapely/cdp_retry.py,sha256=hdTJEAIKhApM7IOk1DrQEl8NoflSJSmqd4RbNJ2IsgI,8540
|
|
6
6
|
scrapely/charging.py,sha256=ns-kuUJtl8hBI4-3iBisC62BggJG67yYOa1yVVItoUI,83800
|
|
@@ -12,7 +12,7 @@ scrapely/patch_browser_pool.py,sha256=R-1QDKa-ZvfdQ9wgyA8JCtmQqD9v7dOsaCZnSUoyf7
|
|
|
12
12
|
scrapely/pricing_types.py,sha256=J6wCddZd-U1MYeOtaaEdeHSsp1HBgiQLfvSInBOvhIo,5305
|
|
13
13
|
scrapely/proxy_configuration.py,sha256=mQhUjXnqM1PcUrnRmXxVWdLnlaRlb8Je4K2j54lC6YQ,38129
|
|
14
14
|
scrapely/py.typed,sha256=XtWlywqUjc6x_M2gAXlDtYXbAsYkCjKZEjFyJvaHvm4,105
|
|
15
|
-
scrapely/solver.py,sha256=
|
|
15
|
+
scrapely/solver.py,sha256=QO7sl_M5AbXRqmCzUowNWG2kBHoXoH7CgtYwAdp36VM,35880
|
|
16
16
|
scrapely/types.py,sha256=ceVuHvhYbPai2CL3vFmXLTMoGaMR27IefJFgWhzd7ws,8900
|
|
17
17
|
scrapely/webhook.py,sha256=4WOM42ypOSOs4lKtP5ofxAh6lX-7c8p5U9lOfuFzx-g,2830
|
|
18
18
|
scrapely/crypto/__init__.py,sha256=MbMPs7Eq_fGSVjOZxNts_JckDCUtxCVqdkHU0VCfN4M,481
|
|
@@ -39,10 +39,10 @@ scrapely/storage/_file_system/_key_value_store_client.py,sha256=4Ipgbh4qEqAkwQJ9
|
|
|
39
39
|
scrapely/storage/_file_system/_storage_client.py,sha256=aaGJ4P0QAtIgEMl6yHpuobeWFD5M4rMC5HwhOOvuGuo,1794
|
|
40
40
|
scrapely/storage_clients/__init__.py,sha256=cs1YX7JV2_GKBXeiiJgkQFali08b5_y_jH6Yw7iROAA,656
|
|
41
41
|
scrapely/storages/__init__.py,sha256=4PAELhJNZ3exJ7Uouicn-bCQ58NafKjhLBixQ8ATQc4,173
|
|
42
|
-
scrapely_python-0.1.
|
|
43
|
-
scrapely_python-0.1.
|
|
44
|
-
scrapely_python-0.1.
|
|
45
|
-
scrapely_python-0.1.
|
|
46
|
-
scrapely_python-0.1.
|
|
47
|
-
scrapely_python-0.1.
|
|
48
|
-
scrapely_python-0.1.
|
|
42
|
+
scrapely_python-0.1.26.dist-info/licenses/LICENSE,sha256=pQGY0XwjIYh-a2HfawxHq1en53bXkFkDj2Q70jKWHr4,1088
|
|
43
|
+
scrapely_python-0.1.26.dist-info/licenses/LICENSE-APACHE,sha256=N8m0FzMq8i4UbTgXZvKEZJSD-27OF8pWZYS_atz4kTU,11355
|
|
44
|
+
scrapely_python-0.1.26.dist-info/licenses/NOTICE,sha256=DEsNrw6UdSIqdYYqMWVFgJnyt6jUivTD7iFU6YM_e1A,1122
|
|
45
|
+
scrapely_python-0.1.26.dist-info/METADATA,sha256=mag9UA_ijOHkoBHTTvSWq2Nai46Okg-M-wkW0aAO-Hk,3487
|
|
46
|
+
scrapely_python-0.1.26.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
47
|
+
scrapely_python-0.1.26.dist-info/top_level.txt,sha256=T4B9UMrs4q99QSAFyD1zdXhl40KnLhBKqrDkPhOTsmY,9
|
|
48
|
+
scrapely_python-0.1.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{scrapely_python-0.1.24.dist-info → scrapely_python-0.1.26.dist-info}/licenses/LICENSE-APACHE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|