forked from Ponysearch/Ponysearch
[fix] engine searchcode.com - paging is broken in searchcode.com's API
paging is broken in searchcode.com's API .. not sure it will ever been fixed / this commit disables paging in the engine and BTW pylint `searchcode_code.py`. Closes: https://github.com/searxng/searxng/issues/3287 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
76b18545e4
commit
3529f0af50
1 changed files with 18 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""
|
# lint: pylint
|
||||||
Searchcode (IT)
|
"""Searchcode (IT)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from json import loads
|
from json import loads
|
||||||
|
@ -18,24 +19,29 @@ about = {
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ['it']
|
categories = ['it']
|
||||||
paging = True
|
search_api = 'https://searchcode.com/api/codesearch_I/?'
|
||||||
|
|
||||||
# search-url
|
|
||||||
url = 'https://searchcode.com/'
|
|
||||||
search_url = url + 'api/codesearch_I/?{query}&p={pageno}'
|
|
||||||
|
|
||||||
# special code-endings which are not recognised by the file ending
|
# special code-endings which are not recognised by the file ending
|
||||||
code_endings = {'cs': 'c#', 'h': 'c', 'hpp': 'cpp', 'cxx': 'cpp'}
|
code_endings = {'cs': 'c#', 'h': 'c', 'hpp': 'cpp', 'cxx': 'cpp'}
|
||||||
|
|
||||||
|
# paging is broken in searchcode.com's API .. not sure it will ever been fixed
|
||||||
|
# paging = True
|
||||||
|
|
||||||
|
|
||||||
# do search-request
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
params['url'] = search_url.format(query=urlencode({'q': query}), pageno=params['pageno'] - 1)
|
args = urlencode(
|
||||||
|
{
|
||||||
|
'q': query,
|
||||||
|
# paging is broken in searchcode.com's API
|
||||||
|
# 'p': params['pageno'] - 1,
|
||||||
|
# 'per_page': 10,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
params['url'] = search_api + args
|
||||||
|
logger.debug("query_url --> %s", params['url'])
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
# get response from search-request
|
|
||||||
def response(resp):
|
def response(resp):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
|
@ -47,7 +53,7 @@ def response(resp):
|
||||||
title = "" + result['name'] + " - " + result['filename']
|
title = "" + result['name'] + " - " + result['filename']
|
||||||
repo = result['repo']
|
repo = result['repo']
|
||||||
|
|
||||||
lines = dict()
|
lines = {}
|
||||||
for line, code in result['lines'].items():
|
for line, code in result['lines'].items():
|
||||||
lines[int(line)] = code
|
lines[int(line)] = code
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue