From 332b58e959e797b32248f7163b1e54ad54eb3007 Mon Sep 17 00:00:00 2001 From: naisanzaa Date: Tue, 15 Oct 2024 05:14:47 +0800 Subject: [PATCH] facebook: add check if login is required to view the page this is an indicator your ip address has been blocked. --- automon/integrations/facebook/groups.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/automon/integrations/facebook/groups.py b/automon/integrations/facebook/groups.py index bee84bc3..8bb8e350 100644 --- a/automon/integrations/facebook/groups.py +++ b/automon/integrations/facebook/groups.py @@ -35,6 +35,22 @@ def __init__(self, url: str = None): self._browser = SeleniumBrowser() + def blocked_by_login(self): + try: + element = self._browser.wait_for_anything( + match='You must log in to continue.', + value='div', + by=self._browser.by.TAG_NAME, + exact_match=True + ) + if element: + element = element[0] + element = element.text + logger.debug(element) + return element + except Exception as error: + logger.error(error) + def close_login_popup(self): try: button = self._browser.find_anything( @@ -553,6 +569,7 @@ def to_dict(self): title=self.title(), url=self.url, visible=self.visible(), + blocked_by_login=self.blocked_by_login() ) def quit(self):