From fc0f06324ce5997e573eaa97b36fd05c096a56d9 Mon Sep 17 00:00:00 2001 From: naisanzaa Date: Sun, 12 Nov 2023 04:43:47 -0800 Subject: [PATCH] facebook: add must_login. update rate_limited --- automon/integrations/facebook/groups.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/automon/integrations/facebook/groups.py b/automon/integrations/facebook/groups.py index 01befdf8..c4b21dbf 100644 --- a/automon/integrations/facebook/groups.py +++ b/automon/integrations/facebook/groups.py @@ -37,6 +37,9 @@ class FacebookGroups(object): '/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', ] + _xpath_must_login = [ + '/html/body/div[1]/div[1]/div[1]/div/div[2]/div/div', + ] _xpath_posts_today = [ '/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[1]/div/div/div[2]/div/div[1]/span', ] @@ -63,6 +66,7 @@ def __init__(self, url: str = None): self._history = None self._members = None self._members_count = None + self._must_login = None self._posts_monthly = None self._posts_monthly_count = None self._posts_today = None @@ -199,6 +203,25 @@ def members_count(self): return self._members_count + def must_login(self): + try: + xpath_must_login = self._browser.wait_for_xpath( + self._xpath_must_login + ) + self._must_login = self._browser.find_xpath( + xpath_must_login + ).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._must_login + @property def posts_monthly(self): if not self._browser: @@ -420,7 +443,7 @@ def get_with_rate_limiter( def rate_limited(self): """rate limit checker""" - if self.temporarily_blocked(): + if self.temporarily_blocked() or self.must_login(): log.info(True) return True