forked from zaclys/searxng
[fix] update startpage engine - closes #1601
This commit is contained in:
parent
3d0c22c58d
commit
77a70fe541
|
@ -15,6 +15,7 @@ from dateutil import parser
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import re
|
import re
|
||||||
from searx.engines.xpath import extract_text
|
from searx.engines.xpath import extract_text
|
||||||
|
from searx.languages import language_codes
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ['general']
|
categories = ['general']
|
||||||
|
@ -22,7 +23,7 @@ categories = ['general']
|
||||||
# (probably the parameter qid), require
|
# (probably the parameter qid), require
|
||||||
# storing of qid's between mulitble search-calls
|
# storing of qid's between mulitble search-calls
|
||||||
|
|
||||||
# paging = False
|
paging = True
|
||||||
language_support = True
|
language_support = True
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
|
@ -32,23 +33,33 @@ search_url = base_url + 'do/search'
|
||||||
# specific xpath variables
|
# specific xpath variables
|
||||||
# ads xpath //div[@id="results"]/div[@id="sponsored"]//div[@class="result"]
|
# ads xpath //div[@id="results"]/div[@id="sponsored"]//div[@class="result"]
|
||||||
# not ads: div[@class="result"] are the direct childs of div[@id="results"]
|
# not ads: div[@class="result"] are the direct childs of div[@id="results"]
|
||||||
results_xpath = '//li[contains(@class, "search-result") and contains(@class, "search-item")]'
|
results_xpath = '//div[@class="w-gl__result"]'
|
||||||
link_xpath = './/h3/a'
|
link_xpath = './/a[@class="w-gl__result-title"]'
|
||||||
content_xpath = './p[@class="search-item__body"]'
|
content_xpath = './/p[@class="w-gl__description"]'
|
||||||
|
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
offset = (params['pageno'] - 1) * 10
|
|
||||||
|
|
||||||
params['url'] = search_url
|
params['url'] = search_url
|
||||||
params['method'] = 'POST'
|
params['method'] = 'POST'
|
||||||
params['data'] = {'query': query,
|
params['data'] = {
|
||||||
'startat': offset}
|
'query': query,
|
||||||
|
'page': params['pageno'],
|
||||||
|
'cat': 'web',
|
||||||
|
'cmd': 'process_search',
|
||||||
|
'engine0': 'v1all',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# set language if specified
|
# set language if specified
|
||||||
if params['language'] != 'all':
|
if params['language'] != 'all':
|
||||||
params['data']['with_language'] = ('lang_' + params['language'].split('-')[0])
|
language = 'english'
|
||||||
|
for lc, _, _, lang in language_codes:
|
||||||
|
if lc == params['language']:
|
||||||
|
language = lang
|
||||||
|
params['data']['language'] = language
|
||||||
|
params['data']['lui'] = language
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue