PlaywrightCapture 1.25.4__py3-none-any.whl → 1.25.5__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.
@@ -165,10 +165,15 @@ class Capture():
165
165
  if proxy:
166
166
  if isinstance(proxy, str):
167
167
  self.proxy = {'server': proxy}
168
- else:
168
+ elif isinstance(proxy, dict):
169
169
  self.proxy = {'server': proxy['server'], 'bypass': proxy.get('bypass', ''),
170
170
  'username': proxy.get('username', ''),
171
171
  'password': proxy.get('password', '')}
172
+ elif isinstance(proxy, int):
173
+ # This is clearly a mistake, just ignoring it
174
+ self.logger.warning('Proxy is an integer, this is a mistake, ignoring it.')
175
+ else:
176
+ raise InvalidPlaywrightParameter(f'Invalid proxy parameter: "{proxy}" ({type(proxy)})')
172
177
 
173
178
  self.should_retry: bool = False
174
179
  self.__network_not_idle: int = 2 # makes sure we do not wait for network idle the max amount of time the capture is allowed to take
@@ -812,7 +817,7 @@ class Capture():
812
817
  try:
813
818
  await page.locator(f'id={fragment}').first.scroll_into_view_if_needed(timeout=3000)
814
819
  await self._wait_for_random_timeout(page, 2)
815
- async with timeout(3):
820
+ async with timeout(5):
816
821
  await page.mouse.wheel(delta_y=random.uniform(150, 300), delta_x=0)
817
822
  self.logger.debug('Jumped to fragment.')
818
823
  except PlaywrightTimeoutError as e:
@@ -821,20 +826,24 @@ class Capture():
821
826
  self.logger.warning(f'Target closed, unable to go to fragment "{fragment}": {e}')
822
827
  except Error as e:
823
828
  self.logger.exception(f'Unable to go to fragment "{fragment}": {e}')
824
- except TimeoutError:
829
+ except (asyncio.TimeoutError, TimeoutError):
825
830
  self.logger.debug('Unable to scroll due to timeout')
831
+ except (asyncio.CancelledError):
832
+ self.logger.debug('Unable to scroll due to timeout, call canceled')
826
833
  else:
827
834
  # scroll more
828
835
  try:
829
836
  # NOTE using page.mouse.wheel causes the instrumentation to fail, sometimes.
830
837
  # 2024-07-08: Also, it sometimes get stuck.
831
- async with timeout(3):
838
+ async with timeout(5):
832
839
  await page.mouse.wheel(delta_y=random.uniform(1500, 3000), delta_x=0)
833
840
  self.logger.debug('Scrolled down.')
834
841
  except Error as e:
835
842
  self.logger.debug(f'Unable to scroll: {e}')
836
- except TimeoutError:
843
+ except (TimeoutError, asyncio.TimeoutError):
837
844
  self.logger.debug('Unable to scroll due to timeout')
845
+ except (asyncio.CancelledError):
846
+ self.logger.debug('Unable to scroll due to timeout, call canceled')
838
847
 
839
848
  await self._wait_for_random_timeout(page, 3)
840
849
  self.logger.debug('Keep going after moving on page.')
@@ -870,7 +879,7 @@ class Capture():
870
879
  # async with timeout(3):
871
880
  # await page.clock.run_for("47")
872
881
  # self.logger.debug('Moved time forward.')
873
- # except TimeoutError:
882
+ # except (TimeoutError, asyncio.TimeoutError):
874
883
  # self.logger.warning('Unable to move time forward.')
875
884
 
876
885
  self.logger.debug('Done with instrumentation, waiting for network idle.')
@@ -919,7 +928,7 @@ class Capture():
919
928
  rendered_hostname_only=rendered_hostname_only,
920
929
  max_depth_capture_time=max_capture_time)
921
930
  to_return['children'].append(child_capture) # type: ignore[union-attr]
922
- except (TimeoutError, asyncio.exceptions.TimeoutError, asyncio.TimeoutError):
931
+ except (TimeoutError, asyncio.TimeoutError):
923
932
  self.logger.info(f'Timeout error, took more than {max_capture_time}s. Unable to capture {url}.')
924
933
  consecutive_errors += 1
925
934
  except Exception as e:
@@ -947,6 +956,9 @@ class Capture():
947
956
  except PlaywrightTimeoutError as e:
948
957
  to_return['error'] = f"The capture took too long - {e.message}"
949
958
  self.should_retry = True
959
+ except (asyncio.TimeoutError, TimeoutError):
960
+ to_return['error'] = "Something in the capture took too long"
961
+ self.should_retry = True
950
962
  except TargetClosedError as e:
951
963
  to_return['error'] = f"The target was closed - {e}"
952
964
  self.should_retry = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PlaywrightCapture
3
- Version: 1.25.4
3
+ Version: 1.25.5
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
@@ -1,9 +1,9 @@
1
1
  playwrightcapture/__init__.py,sha256=F90Y8wYS13tDjgsfjuFrCfmzQfdnH44G-ovuilJfLEE,511
2
- playwrightcapture/capture.py,sha256=ANNPmaTgAIDihdqRDXkuc4LBjZeqcA7EAQpr7zXEpww,70047
2
+ playwrightcapture/capture.py,sha256=rPzmotG1_o-SS0I6oJbMPnVoVweSS_BQ-zUdDaInEsg,70897
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.25.4.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
- playwrightcapture-1.25.4.dist-info/METADATA,sha256=gsWFbtAU24Ag1VpP65y6M3tOl5wTy2dWWVNf5AmOETU,3173
8
- playwrightcapture-1.25.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
- playwrightcapture-1.25.4.dist-info/RECORD,,
6
+ playwrightcapture-1.25.5.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
+ playwrightcapture-1.25.5.dist-info/METADATA,sha256=KfTBTvcCfRoKhAZVGUXjoYfXODyrBFc0iWjTZeWwZ-I,3173
8
+ playwrightcapture-1.25.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
+ playwrightcapture-1.25.5.dist-info/RECORD,,