From 286e1004fd991e496be5d7cf0552da497da23757 Mon Sep 17 00:00:00 2001 From: Shelton Xia <79330016+chengxuan-xia@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:53:33 -0700 Subject: [PATCH] Update selenium.py make format action --- chromegpt/tools/selenium.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/chromegpt/tools/selenium.py b/chromegpt/tools/selenium.py index 0210bc1..005f996 100644 --- a/chromegpt/tools/selenium.py +++ b/chromegpt/tools/selenium.py @@ -317,7 +317,7 @@ def scroll(self, direction: str) -> str: def _get_website_main_content(self, soup: BeautifulSoup) -> str: texts = [ - element.get_text(separator=' ') for element in soup.find_all(string=True) + element.get_text(separator=" ") for element in soup.find_all(string=True) ] pretty_texts = [prettify_text(text) for text in texts] if not pretty_texts: @@ -339,8 +339,8 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str: or (tag.name == "div" and tag.get("role") == "button") or tag.name == "a" or ( - tag.name == "input" - and tag.get("type") + tag.name == "input" + and tag.get("type") in ["checkbox", "submit", "button", "radio", "reset"] ) or tag.has_attr("data-href") @@ -352,10 +352,7 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str: # Detect if size is visible if element.get("style") and "display: none" in element.get("style"): continue - if ( - "style" in element.attrs - and "display: none" in element["style"] - ): + if "style" in element.attrs and "display: none" in element["style"]: continue button_text = ( @@ -367,7 +364,9 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str: ) if button_text: - button_text = prettify_text(button_text, limit=50, remove_special_char=True) + button_text = prettify_text( + button_text, limit=50, remove_special_char=True + ) if button_text not in interactable_texts: interactable_texts.append(button_text)