summaryrefslogtreecommitdiff
path: root/searx/engines/github.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-10-20 21:53:49 +0200
committerasciimoo <asciimoo@gmail.com>2013-10-20 21:53:49 +0200
commit42d2cc2068f1cc456a61d3ccd445ac26a0493d3b (patch)
treee484e5a22ef2cccc36121dd2857e3d622dfc1f9a /searx/engines/github.py
parent7ce7aaed3de51164e6855c18ffcd3a9c2a90f318 (diff)
downloadsearxng-42d2cc2068f1cc456a61d3ccd445ac26a0493d3b.tar.gz
searxng-42d2cc2068f1cc456a61d3ccd445ac26a0493d3b.zip
[enh] github engine added
Diffstat (limited to 'searx/engines/github.py')
-rw-r--r--searx/engines/github.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/searx/engines/github.py b/searx/engines/github.py
new file mode 100644
index 000000000..e6af380d6
--- /dev/null
+++ b/searx/engines/github.py
@@ -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