From 9ca2a745d9ff01458a5651c8a40628c856a89b89 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 15 Oct 2017 15:32:35 -0400 Subject: [PATCH] Caught argument errors and rxed the exception for output --- src/main/utils/scraper.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/utils/scraper.py b/src/main/utils/scraper.py index c752d90..73b03e6 100644 --- a/src/main/utils/scraper.py +++ b/src/main/utils/scraper.py @@ -1,3 +1,5 @@ +import re + from bs4 import BeautifulSoup from lxml import html @@ -10,10 +12,13 @@ async def check_match(url): try: value = BeautifulSoup(content, 'html.parser').find_all('a')[1].get('href') + if value != '#': + return value + else: + raise IndexError except IndexError: - raise exc.MatchError(url) + try: + raise exc.MatchError(re.search('\/([^\/]+)$', url).group(1)) - if value != '#': - return value - else: - raise exc.MatchError(url) + except AttributeError: + raise exc.MissingArgument