summaryrefslogtreecommitdiff
path: root/searx/engines/google_images.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-10-19 23:13:21 +0200
committerasciimoo <asciimoo@gmail.com>2013-10-19 23:13:21 +0200
commit4e5624a50771e8ed71d2fb7c3357df98131c0202 (patch)
tree17e54e4166557fece5c630843f469fe30c430d6c /searx/engines/google_images.py
parent83af0b62246b29169f6295f940b3e0ba67d3a4cf (diff)
downloadsearxng-4e5624a50771e8ed71d2fb7c3357df98131c0202.tar.gz
searxng-4e5624a50771e8ed71d2fb7c3357df98131c0202.zip
[mod] engine rename
Diffstat (limited to 'searx/engines/google_images.py')
-rwxr-xr-xsearx/engines/google_images.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py
new file mode 100755
index 000000000..4ca3fe445
--- /dev/null
+++ b/searx/engines/google_images.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+from urllib import urlencode
+from json import loads
+
+categories = ['images']
+
+search_url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&start=0&rsz=large&safe=off&filter=off&'
+
+def request(query, params):
+ global search_url
+ params['url'] = search_url + urlencode({'q': query})
+ return params
+
+def response(resp):
+ global base_url
+ results = []
+ search_res = loads(resp.text)
+ if 'responseData' not in search_res:
+ return []
+ for result in search_res['responseData']['results']:
+ url = result['originalContextUrl']
+ title = result['title']
+ content = result['content']+'<br /><a href="%s"><img src="%s" title="%s" style="max-width: 500px; "/></a>' % (result['url'], result['url'], title)
+ results.append({'url': url, 'title': title, 'content': content})
+ return results