From 84f45d4f7de79af239d6ea6091aa917c0f8f55d7 Mon Sep 17 00:00:00 2001 From: Myned Date: Sat, 14 Oct 2017 21:54:29 -0400 Subject: [PATCH] Formatting tweaks --- src/main/utils/scraper.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/utils/scraper.py b/src/main/utils/scraper.py index 818e41c..4d7aef6 100644 --- a/src/main/utils/scraper.py +++ b/src/main/utils/scraper.py @@ -1,4 +1,3 @@ -import aiohttp as aio from bs4 import BeautifulSoup from lxml import html @@ -8,10 +7,13 @@ from utils import utils as u async def check_match(url): r = await u.fetch('http://iqdb.harry.lu/?url={}'.format(url)) - soup = BeautifulSoup(await r.read(), 'html.parser') - value = soup.find_all('a')[1].get('href') + + try: + value = BeautifulSoup(await r.read(), 'html.parser').find_all('a')[1].get('href') + except IndexError: + raise exc.MatchError if value != '#': return value else: - raise exc.MatchError(value) + raise exc.MatchError