PlaywrightCapture 1.25.4__tar.gz → 1.25.5__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.
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/PKG-INFO +1 -1
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/playwrightcapture/capture.py +19 -7
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/pyproject.toml +1 -1
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/LICENSE +0 -0
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/README.md +0 -0
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/playwrightcapture/__init__.py +0 -0
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/playwrightcapture/exceptions.py +0 -0
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/playwrightcapture/helpers.py +0 -0
- {playwrightcapture-1.25.4 → playwrightcapture-1.25.5}/playwrightcapture/py.typed +0 -0
@@ -165,10 +165,15 @@ class Capture():
|
|
165
165
|
if proxy:
|
166
166
|
if isinstance(proxy, str):
|
167
167
|
self.proxy = {'server': proxy}
|
168
|
-
|
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(
|
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(
|
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.
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|