diff options
author | asciimoo <asciimoo@gmail.com> | 2013-10-19 23:13:21 +0200 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2013-10-19 23:13:21 +0200 |
commit | 4e5624a50771e8ed71d2fb7c3357df98131c0202 (patch) | |
tree | 17e54e4166557fece5c630843f469fe30c430d6c /searx/engines/google_images.py | |
parent | 83af0b62246b29169f6295f940b3e0ba67d3a4cf (diff) | |
download | searxng-4e5624a50771e8ed71d2fb7c3357df98131c0202.tar.gz searxng-4e5624a50771e8ed71d2fb7c3357df98131c0202.zip |
[mod] engine rename
Diffstat (limited to 'searx/engines/google_images.py')
-rwxr-xr-x | searx/engines/google_images.py | 26 |
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 |