abrasio 0.2.2__tar.gz → 0.2.4__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.
Files changed (42) hide show
  1. {abrasio-0.2.2 → abrasio-0.2.4}/PKG-INFO +2 -2
  2. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/_api.py +12 -0
  3. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/cloud/api_client.py +45 -5
  4. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/cloud/browser.py +12 -0
  5. {abrasio-0.2.2 → abrasio-0.2.4}/pyproject.toml +1 -1
  6. {abrasio-0.2.2 → abrasio-0.2.4}/.github/workflows/publish.yml +0 -0
  7. {abrasio-0.2.2 → abrasio-0.2.4}/.gitignore +0 -0
  8. {abrasio-0.2.2 → abrasio-0.2.4}/LICENSE +0 -0
  9. {abrasio-0.2.2 → abrasio-0.2.4}/README.md +0 -0
  10. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/__init__.py +0 -0
  11. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/_config.py +0 -0
  12. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/_exceptions.py +0 -0
  13. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/cloud/__init__.py +0 -0
  14. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/http/__init__.py +0 -0
  15. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/http/client.py +0 -0
  16. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/human/__init__.py +0 -0
  17. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/human/actions.py +0 -0
  18. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/local/__init__.py +0 -0
  19. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/local/browser.py +0 -0
  20. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/local/stealth/__init__.py +0 -0
  21. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/local/stealth/scripts.py +0 -0
  22. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/sync_api/__init__.py +0 -0
  23. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/sync_api/_sync.py +0 -0
  24. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/utils/__init__.py +0 -0
  25. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/utils/certificates.py +0 -0
  26. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/utils/fingerprint.py +0 -0
  27. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/utils/geolocation.py +0 -0
  28. {abrasio-0.2.2 → abrasio-0.2.4}/abrasio/utils/human.py +0 -0
  29. {abrasio-0.2.2 → abrasio-0.2.4}/docs/api-reference.md +0 -0
  30. {abrasio-0.2.2 → abrasio-0.2.4}/docs/cloud-mode.md +0 -0
  31. {abrasio-0.2.2 → abrasio-0.2.4}/docs/configuration.md +0 -0
  32. {abrasio-0.2.2 → abrasio-0.2.4}/docs/fingerprint.md +0 -0
  33. {abrasio-0.2.2 → abrasio-0.2.4}/docs/getting-started.md +0 -0
  34. {abrasio-0.2.2 → abrasio-0.2.4}/docs/human-behavior.md +0 -0
  35. {abrasio-0.2.2 → abrasio-0.2.4}/docs/index.md +0 -0
  36. {abrasio-0.2.2 → abrasio-0.2.4}/examples/basic_cloud.py +0 -0
  37. {abrasio-0.2.2 → abrasio-0.2.4}/examples/basic_local.py +0 -0
  38. {abrasio-0.2.2 → abrasio-0.2.4}/examples/basic_local_sync.py +0 -0
  39. {abrasio-0.2.2 → abrasio-0.2.4}/examples/certificado.py +0 -0
  40. {abrasio-0.2.2 → abrasio-0.2.4}/examples/fingerprint_check.py +0 -0
  41. {abrasio-0.2.2 → abrasio-0.2.4}/examples/human_behavior.py +0 -0
  42. {abrasio-0.2.2 → abrasio-0.2.4}/examples/tls_fingerprint.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: abrasio
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Stealth web scraping SDK with optional cloud browser support
5
5
  Project-URL: Homepage, https://github.com/Scrape-Technology/abrasio-sdk
6
6
  Project-URL: Documentation, https://scrapetechnology.com/abrasio
@@ -248,6 +248,18 @@ class Abrasio:
248
248
  retry_backoff=retry_backoff,
249
249
  )
250
250
 
251
+ async def get_artifacts(self):
252
+ """
253
+ List files downloaded by the browser during this session (cloud mode only),
254
+ each with a presigned S3 URL valid for ~1h.
255
+
256
+ Returns:
257
+ List of {filename, size, download_url, created_at}
258
+ """
259
+ if not self._browser or not hasattr(self._browser, "get_artifacts"):
260
+ raise AbrasioError("get_artifacts() is only available in cloud mode.")
261
+ return await self._browser.get_artifacts()
262
+
251
263
  @property
252
264
  def live_view_url(self) -> Optional[str]:
253
265
  """Get the live view URL for real-time browser streaming (cloud mode only)."""
@@ -4,6 +4,7 @@ from typing import Optional, Dict, Any, Tuple
4
4
  import base64
5
5
  import logging
6
6
  import asyncio
7
+ import time
7
8
  import uuid
8
9
 
9
10
  import httpx
@@ -226,10 +227,27 @@ class AbrasioAPIClient:
226
227
  TimeoutError: Session didn't become ready in time
227
228
  SessionError: Session failed
228
229
  """
229
- elapsed = 0
230
+ # Bug fix: this used to track "elapsed" by counting loop iterations
231
+ # (`elapsed += poll_interval`) rather than real time. get_session()
232
+ # has its own retry-with-backoff (up to ~3 retries, tens of seconds
233
+ # each on 429/502/503/504), so a single slow iteration could burn far
234
+ # more than poll_interval seconds while only ever counting as one —
235
+ # letting the real wait balloon to many times timeout_seconds, or
236
+ # never time out at all under sustained API flakiness. Track real
237
+ # wall-clock time instead, and bound each get_session() call to
238
+ # whatever time remains so the total can't overrun the budget either.
239
+ deadline = time.monotonic() + timeout_seconds
240
+
241
+ while True:
242
+ remaining = deadline - time.monotonic()
243
+ if remaining <= 0:
244
+ break
245
+
246
+ try:
247
+ session = await asyncio.wait_for(self.get_session(session_id), timeout=remaining)
248
+ except asyncio.TimeoutError:
249
+ break
230
250
 
231
- while elapsed < timeout_seconds:
232
- session = await self.get_session(session_id)
233
251
  status = session.get("status")
234
252
 
235
253
  if status == "READY":
@@ -244,8 +262,10 @@ class AbrasioAPIClient:
244
262
  raise SessionError("Session already finished", session_id)
245
263
 
246
264
  logger.debug(f"Session {session_id} status: {status}, waiting...")
247
- await asyncio.sleep(poll_interval)
248
- elapsed += poll_interval
265
+ remaining = deadline - time.monotonic()
266
+ if remaining <= 0:
267
+ break
268
+ await asyncio.sleep(min(poll_interval, remaining))
249
269
 
250
270
  raise TimeoutError(
251
271
  f"Session {session_id} did not become ready within {timeout_seconds}s",
@@ -352,6 +372,26 @@ class AbrasioAPIClient:
352
372
  """
353
373
  return await self._request_with_retry("post", f"/v1/browser/session/{session_id}/finish")
354
374
 
375
+ async def get_session_artifacts(self, session_id: str) -> Any:
376
+ """
377
+ List files downloaded by the browser during this session.
378
+
379
+ Each entry has a presigned S3 URL (valid ~1h) the caller can fetch
380
+ directly — no further Abrasio API calls needed to get the bytes.
381
+
382
+ Args:
383
+ session_id: Session ID
384
+
385
+ Returns:
386
+ List of {filename, size, download_url, created_at}
387
+
388
+ Raises:
389
+ SessionError: Session not found or not owned by this API key
390
+ """
391
+ return await self._request_with_retry(
392
+ "get", f"/v1/browser/session/{session_id}/artifacts"
393
+ )
394
+
355
395
  def _handle_response(self, response: httpx.Response) -> Dict[str, Any]:
356
396
  """Handle API response and raise appropriate exceptions."""
357
397
  if response.status_code == 200:
@@ -271,6 +271,18 @@ class CloudBrowser:
271
271
  timeout=timeout,
272
272
  )
273
273
 
274
+ async def get_artifacts(self) -> Any:
275
+ """
276
+ List files downloaded by the browser during this session, each with
277
+ a presigned S3 URL to fetch the bytes directly.
278
+
279
+ Returns:
280
+ List of {filename, size, download_url, created_at}
281
+ """
282
+ if not self._api_client or not self._session_id:
283
+ raise RuntimeError("Browser not started or session not active")
284
+ return await self._api_client.get_session_artifacts(self._session_id)
285
+
274
286
  async def new_page(self) -> Page:
275
287
  """
276
288
  Create a new page.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "abrasio"
7
- version = "0.2.2"
7
+ version = "0.2.4"
8
8
  description = "Stealth web scraping SDK with optional cloud browser support"
9
9
  readme = "README.md"
10
10
  license = "MIT"
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