2017-09-24 15:05:28 +00:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
from lxml import html
|
2017-10-13 02:30:40 +00:00
|
|
|
|
2017-09-24 15:05:28 +00:00
|
|
|
from misc import exceptions as exc
|
2017-10-13 02:30:40 +00:00
|
|
|
from utils import utils as u
|
|
|
|
|
2017-09-24 15:05:28 +00:00
|
|
|
|
2017-10-13 02:30:40 +00:00
|
|
|
async def check_match(url):
|
2017-10-15 02:37:57 +00:00
|
|
|
content = await u.fetch('http://iqdb.harry.lu', params={'url': url})
|
2017-10-15 01:54:29 +00:00
|
|
|
|
|
|
|
try:
|
2017-10-15 02:37:57 +00:00
|
|
|
value = BeautifulSoup(content, 'html.parser').find_all('a')[1].get('href')
|
2017-10-15 01:54:29 +00:00
|
|
|
except IndexError:
|
2017-10-15 18:20:11 +00:00
|
|
|
raise exc.MatchError(url)
|
2017-10-13 02:30:40 +00:00
|
|
|
|
2017-09-24 15:05:28 +00:00
|
|
|
if value != '#':
|
|
|
|
return value
|
|
|
|
else:
|
2017-10-15 18:20:11 +00:00
|
|
|
raise exc.MatchError(url)
|