mirror of
https://github.com/searxng/searxng.git
synced 2024-11-27 05:11:03 +00:00
[fix] code cleanup
This commit is contained in:
parent
a48028b771
commit
727c7226d9
1 changed files with 4 additions and 10 deletions
|
@ -1,7 +1,6 @@
|
|||
import json
|
||||
from requests import get
|
||||
from urllib import urlencode
|
||||
from datetime import datetime
|
||||
|
||||
resultCount=2
|
||||
urlSearch = 'https://www.wikidata.org/w/api.php?action=query&list=search&format=json&srnamespace=0&srprop=sectiontitle&{query}'
|
||||
|
@ -10,7 +9,6 @@ urlMap = 'https://www.openstreetmap.org/?lat={latitude}&lon={longitude}&zoom={zo
|
|||
|
||||
def request(query, params):
|
||||
params['url'] = urlSearch.format(query=urlencode({'srsearch': query, 'srlimit': resultCount}))
|
||||
print params['url']
|
||||
return params
|
||||
|
||||
|
||||
|
@ -27,9 +25,7 @@ def response(resp):
|
|||
language = 'en'
|
||||
url = urlDetail.format(query=urlencode({'ids': '|'.join(wikidata_ids), 'languages': language + '|en'}))
|
||||
|
||||
before = datetime.now()
|
||||
htmlresponse = get(url)
|
||||
print datetime.now() - before
|
||||
jsonresponse = json.loads(htmlresponse.content)
|
||||
for wikidata_id in wikidata_ids:
|
||||
results = results + getDetail(jsonresponse, wikidata_id, language)
|
||||
|
@ -144,7 +140,6 @@ def get_string(claims, propertyName, defaultValue=None):
|
|||
for e in propValue:
|
||||
mainsnak = e.get('mainsnak', {})
|
||||
|
||||
datatype = mainsnak.get('datatype', '')
|
||||
datavalue = mainsnak.get('datavalue', {})
|
||||
if datavalue != None:
|
||||
result.append(datavalue.get('value', ''))
|
||||
|
@ -164,7 +159,6 @@ def get_time(claims, propertyName, defaultValue=None):
|
|||
for e in propValue:
|
||||
mainsnak = e.get('mainsnak', {})
|
||||
|
||||
datatype = mainsnak.get('datatype', '')
|
||||
datavalue = mainsnak.get('datavalue', {})
|
||||
if datavalue != None:
|
||||
value = datavalue.get('value', '')
|
||||
|
|
Loading…
Reference in a new issue