.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.searchcode_code Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['it']
 
str search_api = 'https://searchcode.com/api/codesearch_I/?'
 
dict code_endings = {'cs': 'c#', 'h': 'c', 'hpp': 'cpp', 'cxx': 'cpp'}
 

Detailed Description

Searchcode (IT)

Function Documentation

◆ request()

searx.engines.searchcode_code.request ( query,
params )

Definition at line 30 of file searchcode_code.py.

30def request(query, params):
31 args = urlencode(
32 {
33 'q': query,
34 # paging is broken in searchcode.com's API
35 # 'p': params['pageno'] - 1,
36 # 'per_page': 10,
37 }
38 )
39 params['url'] = search_api + args
40 logger.debug("query_url --> %s", params['url'])
41 return params
42
43

◆ response()

searx.engines.searchcode_code.response ( resp)

Definition at line 44 of file searchcode_code.py.

44def response(resp):
45 results = []
46
47 search_results = loads(resp.text)
48
49 # parse results
50 for result in search_results.get('results', []):
51 href = result['url']
52 title = "" + result['name'] + " - " + result['filename']
53 repo = result['repo']
54
55 lines = {}
56 for line, code in result['lines'].items():
57 lines[int(line)] = code
58
59 code_language = code_endings.get(
60 result['filename'].split('.')[-1].lower(), result['filename'].split('.')[-1].lower()
61 )
62
63 # append result
64 results.append(
65 {
66 'url': href,
67 'title': title,
68 'content': '',
69 'repository': repo,
70 'codelines': sorted(lines.items()),
71 'code_language': code_language,
72 'template': 'code.html',
73 }
74 )
75
76 # return results
77 return results

Variable Documentation

◆ about

dict searx.engines.searchcode_code.about
Initial value:
1= {
2 "website": 'https://searchcode.com/',
3 "wikidata_id": None,
4 "official_api_documentation": 'https://searchcode.com/api/',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 10 of file searchcode_code.py.

◆ categories

list searx.engines.searchcode_code.categories = ['it']

Definition at line 20 of file searchcode_code.py.

◆ code_endings

dict searx.engines.searchcode_code.code_endings = {'cs': 'c#', 'h': 'c', 'hpp': 'cpp', 'cxx': 'cpp'}

Definition at line 24 of file searchcode_code.py.

◆ search_api

str searx.engines.searchcode_code.search_api = 'https://searchcode.com/api/codesearch_I/?'

Definition at line 21 of file searchcode_code.py.