Handle error when parsing image result url

このコミットが含まれているのは:
Ben Busby 2021-06-16 10:40:18 -04:00
コミット d894bd347d
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 3B08611DF6E62ED2
2個のファイルの変更12行の追加5行の削除

ファイルの表示

@ -313,12 +313,19 @@ class Filter:
urls = item.find('a')['href'].split('&imgrefurl=')
img_url = urlparse.unquote(urls[0].replace('/imgres?imgurl=', ''))
webpage = urlparse.unquote(urls[1].split('&')[0])
try:
# Try to strip out only the necessary part of the web page link
web_page = urlparse.unquote(urls[1].split('&')[0])
except IndexError:
web_page = urlparse.unquote(urls[1])
img_tbn = urlparse.unquote(item.find('a').find('img')['src'])
results.append({
'domain': urlparse.urlparse(webpage).netloc,
'domain': urlparse.urlparse(web_page).netloc,
'img_url': img_url,
'webpage': webpage,
'web_page': web_page,
'img_tbn': img_tbn
})

ファイルの表示

@ -64,7 +64,7 @@
<table class="TxbwNb">
<tr>
<td>
<a href="{{ results[(i*4)+j].webpage }}">
<a href="{{ results[(i*4)+j].web_page }}">
<div class="RAyV4b">
<img alt="" class="t0fcAb" src="{{ results[(i*4)+j].img_tbn }}"/>
</div>
@ -73,7 +73,7 @@
</tr>
<tr>
<td>
<a href="{{ results[(i*4)+j].webpage }}">
<a href="{{ results[(i*4)+j].web_page }}">
<div class="Tor4Ec">
<span class="qXLe6d x3G5ab">
<span class="fYyStc">