PlaywrightCapture 1.24.3__py3-none-any.whl → 1.24.4__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.
@@ -681,7 +681,10 @@ class Capture():
681
681
  self.should_retry = True
682
682
  except Exception:
683
683
  raise e
684
- elif self._exception_is_network_error(initial_error):
684
+ else:
685
+ if not self._exception_is_network_error(initial_error):
686
+ # TODO: Do something?
687
+ self.logger.warning(f'Unexpected error: {initial_error}')
685
688
  raise initial_error
686
689
  else:
687
690
  await page.bring_to_front()
@@ -718,8 +721,8 @@ class Capture():
718
721
  if allow_tracking:
719
722
  await self._wait_for_random_timeout(page, 2)
720
723
  # This event is required trigger the add_locator_handler
721
- if await page.locator("body").is_visible():
722
- await page.locator("body").click(button="right", timeout=2000)
724
+ if await page.locator("body").first.is_visible():
725
+ await page.locator("body").first.click(button="right", timeout=2000)
723
726
 
724
727
  # move mouse
725
728
  await page.mouse.move(x=random.uniform(300, 800), y=random.uniform(200, 500))
@@ -864,7 +867,9 @@ class Capture():
864
867
  'Connection closed',
865
868
  'Navigation interrupted by another one',
866
869
  'Navigation failed because page was closed!',
867
- 'Protocol error (Page.bringToFront): Not attached to an active page']:
870
+ 'Protocol error (Page.bringToFront): Not attached to an active page',
871
+ 'Peer failed to perform TLS handshake: The TLS connection was non-properly terminated.',
872
+ 'Load cannot follow more than 20 redirections']:
868
873
  # Other errors, let's give it another shot
869
874
  self.logger.info(f'Issue with {url} (retrying): {e.message}')
870
875
  self.should_retry = True
@@ -872,6 +877,9 @@ class Capture():
872
877
  # The browser barfed, let's try again
873
878
  self.logger.info(f'Browser barfed on {url} (retrying): {e.message}')
874
879
  self.should_retry = True
880
+ elif e.name in ['net::ERR_INVALID_AUTH_CREDENTIALS']:
881
+ # No need to retry, the credentials are wrong/missing.
882
+ pass
875
883
  else:
876
884
  # Unexpected ones
877
885
  self.logger.exception(f'Something went poorly with {url}: {e.message}')
@@ -932,8 +940,8 @@ class Capture():
932
940
  max_wait = force_max_wait_in_sec
933
941
  else:
934
942
  max_wait = self._capture_timeout / self.__network_not_idle
935
- max_wait *= 1000
936
943
  self.logger.debug(f'Waiting for network idle, max wait: {max_wait}s')
944
+ max_wait *= 1000
937
945
  # If we don't have networkidle relatively quick, it's probably because we're playing a video.
938
946
  await page.wait_for_load_state('networkidle', timeout=max_wait)
939
947
  except PlaywrightTimeoutError:
@@ -1103,8 +1111,11 @@ class Capture():
1103
1111
  'net::ERR_CONNECTION_CLOSED',
1104
1112
  'net::ERR_CONNECTION_REFUSED',
1105
1113
  'net::ERR_CONNECTION_RESET',
1114
+ 'net::ERR_CONNECTION_TIMED_OUT',
1106
1115
  'net::ERR_EMPTY_RESPONSE',
1116
+ 'net::ERR_HTTP_RESPONSE_CODE_FAILURE',
1107
1117
  'net::ERR_HTTP2_PROTOCOL_ERROR',
1118
+ 'net::ERR_INVALID_RESPONSE',
1108
1119
  'net::ERR_NAME_NOT_RESOLVED',
1109
1120
  'net::ERR_SOCKS_CONNECTION_FAILED',
1110
1121
  'net::ERR_SSL_UNRECOGNIZED_NAME_ALERT',
@@ -1251,8 +1262,14 @@ class Capture():
1251
1262
  # unable to identify the mimetype
1252
1263
  self.logger.debug(f'Unable to identify the mimetype for favicon from {u}')
1253
1264
  else:
1254
- if mimetype.startswith('image'):
1265
+ if not mimetype:
1266
+ # empty, ignore
1267
+ pass
1268
+ elif mimetype.startswith('image'):
1255
1269
  to_return.add(favicon)
1270
+ elif mimetype.startswith('text'):
1271
+ # Just ignore, it's probably a 404 page
1272
+ pass
1256
1273
  else:
1257
1274
  self.logger.warning(f'Unexpected mimetype for favicon from {u}: {mimetype}')
1258
1275
  self.logger.debug(f'Done with favicon from {u}.')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PlaywrightCapture
3
- Version: 1.24.3
3
+ Version: 1.24.4
4
4
  Summary: A simple library to capture websites using playwright
5
5
  Home-page: https://github.com/Lookyloo/PlaywrightCapture
6
6
  License: BSD-3-Clause
@@ -29,7 +29,7 @@ Requires-Dist: puremagic (>=1.21,<2.0)
29
29
  Requires-Dist: pydub (>=0.25.1,<0.26.0) ; extra == "recaptcha"
30
30
  Requires-Dist: pytz (>=2024.1,<2025.0) ; python_version < "3.9"
31
31
  Requires-Dist: requests[socks] (>=2.31.0,<3.0.0) ; extra == "recaptcha"
32
- Requires-Dist: setuptools (>=69.2.0,<70.0.0)
32
+ Requires-Dist: setuptools (>=69.5.1,<70.0.0)
33
33
  Requires-Dist: tzdata (>=2024.1,<2025.0)
34
34
  Requires-Dist: w3lib (>=2.1.2,<3.0.0)
35
35
  Project-URL: Repository, https://github.com/Lookyloo/PlaywrightCapture
@@ -1,9 +1,9 @@
1
1
  playwrightcapture/__init__.py,sha256=F90Y8wYS13tDjgsfjuFrCfmzQfdnH44G-ovuilJfLEE,511
2
- playwrightcapture/capture.py,sha256=KuIaHzPtZqZKYNDO8WfPx22D6Ms6xKezZmgg4I4yCNs,61485
2
+ playwrightcapture/capture.py,sha256=0QTHf1zgR9jI112Vd-WVezLt6dNocl8nkvBzMAQFVZM,62432
3
3
  playwrightcapture/exceptions.py,sha256=LhGJQCGHzEu7Sx2Dfl28OFeDg1OmrwufFjAWXlxQnEA,366
4
4
  playwrightcapture/helpers.py,sha256=SXQLEuxMs8-bcWykMiUVosHzzxBKuS-QC0gBV3OmKmo,1764
5
5
  playwrightcapture/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- playwrightcapture-1.24.3.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
- playwrightcapture-1.24.3.dist-info/METADATA,sha256=yuyoEKN1Qa5Dcsx0YkWGST9sPFSP7RlClu9FjMWz53A,3077
8
- playwrightcapture-1.24.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
- playwrightcapture-1.24.3.dist-info/RECORD,,
6
+ playwrightcapture-1.24.4.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
+ playwrightcapture-1.24.4.dist-info/METADATA,sha256=NXKwII6UDKaLf-igQQ4RAInjfzZBiXVn7qhdcTe687Y,3077
8
+ playwrightcapture-1.24.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
+ playwrightcapture-1.24.4.dist-info/RECORD,,