Handle missing result div in filter (#911)

Changed "find_all()[0]" for find; which yields only one result.

Added check to ensure result_div exists before searching
for results.
このコミットが含まれているのは:
MoistCat 2022-12-29 17:17:34 -05:00 committed by GitHub
コミット 08aa1ab8f1
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 4AEE18F83AFDEB23
2個のファイルの変更10行の追加4行の削除

4
.gitignore vendored
ファイルの表示

@ -19,3 +19,7 @@ dist/
# env
whoogle.env
# vim
*~
*.swp

ファイルの表示

@ -610,13 +610,15 @@ class Filter:
# get some tags that are unchanged between mobile and pc versions
cor_suggested = soup.find_all('table', attrs={'class': "By0U9"})
next_pages = soup.find_all('table', attrs={'class': "uZgmoc"})[0]
next_pages = soup.find('table', attrs={'class': "uZgmoc"})
results = []
# find results div
results_div = soup.find_all('div', attrs={'class': "nQvrDb"})[0]
# find all the results
results_all = results_div.find_all('div', attrs={'class': "lIMUZd"})
results_div = soup.find('div', attrs={'class': "nQvrDb"})
# find all the results (if any)
results_all = []
if results_div:
results_all = results_div.find_all('div', attrs={'class': "lIMUZd"})
for item in results_all:
urls = item.find('a')['href'].split('&imgrefurl=')