diff options
author | Adam Tauber <asciimoo@gmail.com> | 2016-11-30 18:43:03 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2017-05-15 12:02:30 +0200 |
commit | 52e615dede8538c36f569d2cf07835427a9a0db6 (patch) | |
tree | ac65990c72156def2d49e81d981f0b3beda4fd2e /searx/engines/tokyotoshokan.py | |
parent | 46a2c63f8e1c3819cceff2d61fe9106051e8ecee (diff) | |
download | searxng-52e615dede8538c36f569d2cf07835427a9a0db6.tar.gz searxng-52e615dede8538c36f569d2cf07835427a9a0db6.zip |
[enh] py3 compatibility
Diffstat (limited to 'searx/engines/tokyotoshokan.py')
-rw-r--r-- | searx/engines/tokyotoshokan.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/searx/engines/tokyotoshokan.py b/searx/engines/tokyotoshokan.py index 52b2cbe07..9a6b5e57d 100644 --- a/searx/engines/tokyotoshokan.py +++ b/searx/engines/tokyotoshokan.py @@ -11,11 +11,11 @@ """ import re -from urllib import urlencode from lxml import html from searx.engines.xpath import extract_text from datetime import datetime from searx.engines.nyaa import int_or_zero, get_filesize_mul +from searx.url_utils import urlencode # engine dependent config categories = ['files', 'videos', 'music'] @@ -28,8 +28,7 @@ search_url = base_url + 'search.php?{query}' # do search-request def request(query, params): - query = urlencode({'page': params['pageno'], - 'terms': query}) + query = urlencode({'page': params['pageno'], 'terms': query}) params['url'] = search_url.format(query=query) return params @@ -50,7 +49,7 @@ def response(resp): size_re = re.compile(r'Size:\s*([\d.]+)(TB|GB|MB|B)', re.IGNORECASE) # processing the results, two rows at a time - for i in xrange(0, len(rows), 2): + for i in range(0, len(rows), 2): # parse the first row name_row = rows[i] @@ -79,14 +78,14 @@ def response(resp): groups = size_re.match(item).groups() multiplier = get_filesize_mul(groups[1]) params['filesize'] = int(multiplier * float(groups[0])) - except Exception as e: + except: pass elif item.startswith('Date:'): try: # Date: 2016-02-21 21:44 UTC date = datetime.strptime(item, 'Date: %Y-%m-%d %H:%M UTC') params['publishedDate'] = date - except Exception as e: + except: pass elif item.startswith('Comment:'): params['content'] = item |