mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 19:01:00 +00:00
[enh] added flickr engine
This commit is contained in:
parent
9bc6865ddc
commit
812d307062
1 changed files with 29 additions and 0 deletions
29
searx/engines/flickr.py
Executable file
29
searx/engines/flickr.py
Executable file
|
@ -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
|
Loading…
Reference in a new issue