mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 20:17:45 +01:00
[enh] github engine added
This commit is contained in:
parent
7ce7aaed3d
commit
42d2cc2068
25
searx/engines/github.py
Normal file
25
searx/engines/github.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from urllib import urlencode
|
||||||
|
from json import loads
|
||||||
|
|
||||||
|
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']
|
||||||
|
content = res['description']
|
||||||
|
results.append({'url': url, 'title': title, 'content': content})
|
||||||
|
return results
|
Loading…
Reference in New Issue
Block a user