summaryrefslogtreecommitdiff
path: root/searx/engines/flickr.py
diff options
context:
space:
mode:
authorstef <stefan.marsiske@gmail.com>2013-10-18 02:15:26 +0200
committerstef <stefan.marsiske@gmail.com>2013-10-18 02:15:26 +0200
commit812d307062548a78c6d7f3aaba82c7b56336e54e (patch)
tree0273d332c56d12219c0b862f8cbf015041b1ab3b /searx/engines/flickr.py
parent9bc6865ddc71675f5704c3c3fb9ce4a56ff2d4a1 (diff)
downloadsearxng-812d307062548a78c6d7f3aaba82c7b56336e54e.tar.gz
searxng-812d307062548a78c6d7f3aaba82c7b56336e54e.zip
[enh] added flickr engine
Diffstat (limited to 'searx/engines/flickr.py')
-rwxr-xr-xsearx/engines/flickr.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py
new file mode 100755
index 000000000..3c8d1d931
--- /dev/null
+++ b/searx/engines/flickr.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+from urllib import quote
+from lxml import html
+from urlparse import urljoin
+
+categories = ['img']
+
+base_url = 'https://secure.flickr.com/'
+search_url = base_url+'search/?q='
+
+def request(query, params):
+ global search_url
+ print 'qqwerqwerqwerqwer'
+ query = quote(query.replace(' ', '+'), safe='+')
+ params['url'] = search_url + query
+ return params
+
+def response(resp):
+ global base_url
+ print 'asdfasdfasdf'
+ results = []
+ dom = html.fromstring(resp.text)
+ for result in dom.xpath('//#thumbnails//a'):
+ url = urljoin(base_url, result.attrib.get('href'))
+ title = result.xpath('./img')[0].attrib.get('alt')
+ content = "<img src='%s'></img>" % result.xpath('./img')[0].attrib.get('src')
+ results.append({'url': url, 'title': title, 'content': content})
+ return results