Skip to content

Commit

Permalink
facebook: add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Oct 26, 2023
1 parent c77c222 commit 377ddd8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions automon/integrations/facebook/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def posts_monthly(self):
xpath_monthly_posts = self._browser.wait_for_xpath(self.xpath_posts_monthly)
self._posts_monthly = self._browser.find_xpath(xpath_monthly_posts).text
except Exception as e:
print(f"can't get monthly posts {self.url}: {e}")
log.error(f"can't get monthly posts {self.url}: {e}")

return self._posts_monthly

Expand Down Expand Up @@ -270,23 +270,31 @@ def get(self, url: str = None) -> bool:
self.start()

if not url and not self.url:
log.error(f'missing url')
raise Exception(f"missing url")

return self._browser.get(url=url or self.url)
get = self._browser.get(url=url or self.url)
log.info(f'{get}')
return get

def get_about(self):
url = f'{self.url}/about'
return self.get(url=url)
log.debug(f'get {url}')
get = self.get(url=url)
log.info(f'{get}')
return get

def run(self):
"""run selenium browser"""
if self._browser:
log.info(f'{self._browser}')
return self._browser.run()

def restart(self):
"""quit and start new instance of selenium"""
if self._browser:
self.quit()
log.info(f'{self._browser}')
return self.start()

def start(self, headless: bool = True):
Expand All @@ -298,6 +306,7 @@ def start(self, headless: bool = True):
else:
self._browser.config.set_webdriver.Chrome().set_locale_experimental()

log.info(f'{self._browser}')
return self._browser.run()

def stop(self):
Expand Down Expand Up @@ -343,4 +352,5 @@ def to_dict(self):
def quit(self):
"""quit selenium"""
if self._browser:
log.info(f'{self._browser}')
return self._browser.quit()

0 comments on commit 377ddd8

Please sign in to comment.