PlaywrightCapture 1.25.12__py3-none-any.whl → 1.25.14__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.
@@ -636,6 +636,28 @@ class Capture():
636
636
  )
637
637
  self.logger.info('Yahoo handler added')
638
638
 
639
+ async def __dialog_tarteaucitron_clickthrough(self, page: Page) -> None:
640
+ # https://github.com/AmauriC/tarteaucitron.js/
641
+ async def handler() -> None:
642
+ if await page.locator('#tarteaucitronAlertBig').locator('button.tarteaucitronAllow').is_visible():
643
+ self.logger.debug('Got TarteAuCitron big , clicking through.')
644
+ await page.locator('#tarteaucitronAlertBig').locator("button.tarteaucitronAllow").click(timeout=2000)
645
+ elif await page.locator('#tarteaucitronAlertSmall').locator('button.tarteaucitronAllow').is_visible():
646
+ self.logger.debug('Got TarteAuCitron small, clicking through.')
647
+ await page.locator('#tarteaucitronAlertSmall').locator("button.tarteaucitronAllow").click(timeout=2000)
648
+
649
+ await page.add_locator_handler(
650
+ page.locator('#tarteaucitronAlertBig'),
651
+ handler,
652
+ times=1, no_wait_after=True
653
+ )
654
+ await page.add_locator_handler(
655
+ page.locator('#tarteaucitronAlertSmall'),
656
+ handler,
657
+ times=1, no_wait_after=True
658
+ )
659
+ self.logger.info('TarteAuCitron handler added')
660
+
639
661
  async def __dialog_ppms_clickthrough(self, page: Page) -> None:
640
662
  async def handler() -> None:
641
663
  if await page.locator('.ppms_cm_popup_overlay').locator("button.ppms_cm_agree-to-all").is_visible():
@@ -661,9 +683,12 @@ class Capture():
661
683
  "Tout accepter",
662
684
  "Accepter",
663
685
  "Accepter les cookies",
686
+ "Autoriser",
664
687
  # English
665
688
  "Accept & continue",
666
689
  "Accept all",
690
+ "Accept",
691
+ "Agree and close",
667
692
  # Dutch
668
693
  "Accepteer",
669
694
  # Spanish
@@ -680,21 +705,35 @@ class Capture():
680
705
 
681
706
  got_button: bool = False
682
707
  try:
683
- if await frame.locator("button.button__acceptAll").is_visible():
684
- self.logger.info('Consent window found, clicking through.')
685
- got_button = True
686
- await frame.locator("button.button__acceptAll").click(timeout=2000)
708
+ try:
709
+ async with timeout(5):
710
+ if await frame.locator("button.button__acceptAll").is_visible():
711
+ self.logger.info('Consent window found, clicking through.')
712
+ got_button = True
713
+ await frame.locator("button.button__acceptAll").click(timeout=2000)
714
+ except (TimeoutError, asyncio.TimeoutError) as e:
715
+ self.logger.warning(f'Frame consent timeout: {e}')
716
+
687
717
  for label in labels_to_click:
688
- if await frame.get_by_label(label).is_visible():
689
- got_button = True
690
- self.logger.debug(f'Got button by label on frame: {label}')
691
- await frame.get_by_label(label).click(timeout=2000)
692
- break
693
- if await frame.get_by_role("button", name=label).is_visible():
694
- got_button = True
695
- self.logger.debug(f'Got button by role on frame: {label}')
696
- await frame.get_by_role("button", name=label).click(timeout=2000)
697
- break
718
+ try:
719
+ async with timeout(5):
720
+ if await frame.get_by_label(label).is_visible():
721
+ got_button = True
722
+ self.logger.debug(f'Got button by label on frame: {label}')
723
+ await frame.get_by_label(label).click(timeout=2000)
724
+ break
725
+ except (TimeoutError, asyncio.TimeoutError) as e:
726
+ self.logger.warning(f'Frame consent timeout: {e}')
727
+
728
+ try:
729
+ async with timeout(5):
730
+ if await frame.get_by_role("button", name=label).is_visible():
731
+ got_button = True
732
+ self.logger.debug(f'Got button by role on frame: {label}')
733
+ await frame.get_by_role("button", name=label).click(timeout=2000)
734
+ break
735
+ except (TimeoutError, asyncio.TimeoutError) as e:
736
+ self.logger.warning(f'Frame consent timeout: {e}')
698
737
  except Exception as e:
699
738
  self.logger.info(f'Issue with frame consent: {e}')
700
739
  return got_button
@@ -794,6 +833,7 @@ class Capture():
794
833
  await self.__dialog_ppms_clickthrough(page)
795
834
  await self.__dialog_alert_dialog_clickthrough(page)
796
835
  await self.__dialog_clickthrough(page)
836
+ await self.__dialog_tarteaucitron_clickthrough(page)
797
837
 
798
838
  await stealth_async(page, PCStealthConfig())
799
839
 
@@ -884,8 +924,13 @@ class Capture():
884
924
  self.logger.debug('Done with captcha.')
885
925
 
886
926
  # move mouse
887
- await page.mouse.move(x=random.uniform(300, 800), y=random.uniform(200, 500))
888
- self.logger.debug('Moved mouse.')
927
+ try:
928
+ async with timeout(5):
929
+ await page.mouse.move(x=random.uniform(300, 800), y=random.uniform(200, 500))
930
+ self.logger.debug('Moved mouse.')
931
+ except (asyncio.TimeoutError, TimeoutError):
932
+ self.logger.debug('Moving the mouse caused a timeout.')
933
+
889
934
  await self._wait_for_random_timeout(page, 5)
890
935
  self.logger.debug('Keep going after moving mouse.')
891
936
 
@@ -955,11 +1000,14 @@ class Capture():
955
1000
  self.logger.debug('Keep going after moving on page.')
956
1001
 
957
1002
  try:
958
- await page.keyboard.press('PageUp')
959
- self.logger.debug('PageUp on keyboard')
960
- await self._wait_for_random_timeout(page, 3)
961
- await page.keyboard.press('PageDown')
962
- self.logger.debug('PageDown on keyboard')
1003
+ async with timeout(5):
1004
+ await page.keyboard.press('PageUp')
1005
+ self.logger.debug('PageUp on keyboard')
1006
+ await self._wait_for_random_timeout(page, 3)
1007
+ await page.keyboard.press('PageDown')
1008
+ self.logger.debug('PageDown on keyboard')
1009
+ except (asyncio.TimeoutError, TimeoutError):
1010
+ self.logger.debug('Using keyboard caused a timeout.')
963
1011
  except Error as e:
964
1012
  self.logger.debug(f'Unable to use keyboard: {e}')
965
1013
  if self.wait_for_download > 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PlaywrightCapture
3
- Version: 1.25.12
3
+ Version: 1.25.14
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
@@ -22,7 +22,7 @@ Classifier: Topic :: Security
22
22
  Provides-Extra: recaptcha
23
23
  Requires-Dist: SpeechRecognition (>=3.10.4,<4.0.0) ; extra == "recaptcha"
24
24
  Requires-Dist: aiohttp-socks (>=0.9,<0.10)
25
- Requires-Dist: aiohttp[speedups] (>=3.10.3,<4.0.0)
25
+ Requires-Dist: aiohttp[speedups] (>=3.10.5,<4.0.0)
26
26
  Requires-Dist: async-timeout (>=4.0.3,<5.0.0) ; python_version < "3.11"
27
27
  Requires-Dist: beautifulsoup4[charset-normalizer,lxml] (>=4.12.3,<5.0.0)
28
28
  Requires-Dist: dateparser (>=1.2.0,<2.0.0)
@@ -31,7 +31,7 @@ Requires-Dist: playwright-stealth (>=1.0.6,<2.0.0)
31
31
  Requires-Dist: puremagic (>=1.27,<2.0)
32
32
  Requires-Dist: pydub (>=0.25.1,<0.26.0) ; extra == "recaptcha"
33
33
  Requires-Dist: pytz (>=2024.1,<2025.0) ; python_version < "3.9"
34
- Requires-Dist: setuptools (>=72.2.0,<73.0.0)
34
+ Requires-Dist: setuptools (>=74.0.0,<75.0.0)
35
35
  Requires-Dist: tzdata (>=2024.1,<2025.0)
36
36
  Requires-Dist: w3lib (>=2.2.1,<3.0.0)
37
37
  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=R8ayCKpD1Q78ewaQ8-4tuMP8XVE8YGOwhwVYZDs4a8g,75867
2
+ playwrightcapture/capture.py,sha256=9ESwyexAnBtGc2QV3u4WvOKZqisMVdqHL4rko1RxJXQ,78337
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.12.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
- playwrightcapture-1.25.12.dist-info/METADATA,sha256=Kw9CVpRSN9vLL1XSf_ZGIKAzX11VY4MJuXrO0OVCmHw,3172
8
- playwrightcapture-1.25.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
- playwrightcapture-1.25.12.dist-info/RECORD,,
6
+ playwrightcapture-1.25.14.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
+ playwrightcapture-1.25.14.dist-info/METADATA,sha256=45rFgcxqSi2TAU8KwsE0dxdWja1u7tvHchj0x3H1dCM,3172
8
+ playwrightcapture-1.25.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
+ playwrightcapture-1.25.14.dist-info/RECORD,,