Raise exception on None content

This commit is contained in:
texhno 2024-02-06 03:37:26 +01:00
parent 6df3c82a7e
commit d4d14806db
1 changed files with 2 additions and 0 deletions

View File

@ -8,6 +8,8 @@ def query_external_website(base_url, query):
soup = BeautifulSoup(page.content, "html.parser")
title = soup.find("span", class_="mw-page-title-main").text
content = next((paragraph for paragraph in soup.find(id="mw-content-text").select("p") if not paragraph.has_attr("class")), None)
if content == None:
raise Exception("Can't parse")
return "\nTITLE:\n" + title + "\n\nCONTENT:\n" + content.text + "\n\nFULL LINK:\n" + base_url + quote(query)
except:
return "Can't parse search result :("