mirror of https://github.com/searxng/searxng
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
828 B
Python
30 lines
828 B
Python
from urllib import urlencode
|
|
from json import loads
|
|
from cgi import escape
|
|
|
|
categories = ['it']
|
|
|
|
search_url = 'https://api.github.com/search/repositories?sort=stars&order=desc&'
|
|
|
|
def request(query, params):
|
|
global search_url
|
|
params['url'] = search_url + urlencode({'q': query})
|
|
params['headers']['Accept'] = 'application/vnd.github.preview.text-match+json'
|
|
return params
|
|
|
|
|
|
def response(resp):
|
|
results = []
|
|
search_res = loads(resp.text)
|
|
if not 'items' in search_res:
|
|
return results
|
|
for res in search_res['items']:
|
|
title = res['name']
|
|
url = res['html_url']
|
|
if res['description']:
|
|
content = escape(res['description'][:500])
|
|
else:
|
|
content = ''
|
|
results.append({'url': url, 'title': title, 'content': content})
|
|
return results
|