From 0e6d6b78d84b143d1f26bc355247c6dfb90a7ac8 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Tue, 10 Sep 2024 09:23:16 +0700 Subject: [PATCH] Update misc_tools.py --- misskaty/plugins/misc_tools.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py index 294a20bb4f..37c259d017 100644 --- a/misskaty/plugins/misc_tools.py +++ b/misskaty/plugins/misc_tools.py @@ -336,9 +336,12 @@ async def gsearch(self, message): for result in soup.select(".tF2Cxc"): link = result.select_one(".yuRUbf a")["href"] title = result.select_one(".DKV0Md").text - self.log.info(result) - snippet = result.find(class_="VwiC3b yXK7lf lVm3ye r025kc hJNv6b").get_text() if result.find(class_="VwiC3b yXK7lf lVm3ye r025kc hJNv6b") else "-" - self.log.info(snippet) + if snippet := result.find(class_="VwiC3b yXK7lf lVm3ye r025kc hJNv6b"): + snippet = snippet.get_text() + elif snippet := result.find(class_="LEwnzc Sqrs4e"): + snippet = snippet.get_text() + else: + snippet = "-" # appending data to an array data.append( {