From b14d03b8cd6a3b80a81cd1a04d84adeae80a49e1 Mon Sep 17 00:00:00 2001 From: naisanzaa Date: Tue, 7 Nov 2023 14:03:36 -0800 Subject: [PATCH] facebook: add is_temporarily_blocked --- automon/integrations/facebook/groups.py | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/automon/integrations/facebook/groups.py b/automon/integrations/facebook/groups.py index 087f8ee5..50d43197 100644 --- a/automon/integrations/facebook/groups.py +++ b/automon/integrations/facebook/groups.py @@ -28,6 +28,10 @@ class FacebookGroups(object): _xpath_title = [ '/html/body/div[1]/div/div[1]/div/div[3]/div/div/div/div[1]/div[1]/div[1]/div[2]/div/div/div/div/div[1]/div/div/div/div/div/div[1]/h1/span/a', ] + _xpath_temporarily_blocked = [ + '/html/body/div[1]/div[2]/div[1]/div/div/div[1]/div/div[2]/h2', + '/html/body/div[1]/div[2]/div[1]/div/div/div[1]/div/div[2]', + ] _xpath_members = [ '/html/body/div[1]/div/div[1]/div/div[3]/div/div/div/div[1]/div[1]/div/div[2]/div/div/div[4]/div/div/div/div/div/div[3]/div/div/div/div/div/div[2]/div/div[2]/div/div/div[2]/div/div[1]/span', '/html/body/div[1]/div/div[1]/div/div[3]/div/div/div/div[1]/div[1]/div[4]/div/div/div/div/div/div[3]/div/div/div/div/div/div[2]/div/div[2]/div/div/div[2]/div/div[1]/span', @@ -64,6 +68,7 @@ def __init__(self, url: str = None): self._posts_today_count = None self._privacy = None self._privacy_details = None + self._temporarily_blocked = None self._title = None self._url = url self._visible = None @@ -137,6 +142,28 @@ def history(self): return self._history + def is_temporarily_blocked(self): + if not self._browser: + return + + try: + xpath_temporarily_blocked = self._browser.wait_for_xpath( + self._xpath_temporarily_blocked + ) + self._temporarily_blocked = self._browser.find_xpath( + xpath_temporarily_blocked + ).text + except Exception as error: + message, session, stacktrace = self.error_parsing(error) + log.error(str(dict( + url=self.url, + message=message, + session=session, + stacktrace=stacktrace, + ))) + + return self._temporarily_blocked + @property def members(self): if not self._browser: