mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[mod] int_or_zero refactored to searx_utils
This commit is contained in:
parent
c3232b0e1a
commit
33fd938016
3 changed files with 23 additions and 29 deletions
|
|
@ -15,7 +15,7 @@ from lxml import html
|
|||
from searx.engines.xpath import extract_text
|
||||
from datetime import datetime
|
||||
from searx.url_utils import urlencode
|
||||
from searx.utils import get_torrent_size
|
||||
from searx.utils import get_torrent_size, int_or_zero
|
||||
|
||||
# engine dependent config
|
||||
categories = ['files', 'videos', 'music']
|
||||
|
|
@ -26,17 +26,6 @@ base_url = 'https://www.tokyotosho.info/'
|
|||
search_url = base_url + 'search.php?{query}'
|
||||
|
||||
|
||||
# convert a variable to integer or return 0 if it's not a number
|
||||
def int_or_zero(num):
|
||||
if isinstance(num, list):
|
||||
if len(num) < 1:
|
||||
return 0
|
||||
num = num[0]
|
||||
if num.isdigit():
|
||||
return int(num)
|
||||
return 0
|
||||
|
||||
|
||||
# do search-request
|
||||
def request(query, params):
|
||||
query = urlencode({'page': params['pageno'], 'terms': query})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue