Skip to content

Commit

Permalink
facebook: add must_login. update rate_limited
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Nov 12, 2023
1 parent a226980 commit fc0f063
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion automon/integrations/facebook/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit fc0f063

Please sign in to comment.