summaryrefslogtreecommitdiff
path: root/searx/engines/500px.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2015-01-31 22:05:13 +0100
committerAdam Tauber <asciimoo@gmail.com>2015-01-31 22:05:13 +0100
commitbfd321a7a9cfc6d643fdebe5e7a5824fe70b9aa9 (patch)
treebdbe71be7cff27d0176bf22296ae93c045c619ed /searx/engines/500px.py
parent8de97dac03fc97a9705c8d3cd3163330a6f08375 (diff)
[mod] python importable engine names
Diffstat (limited to 'searx/engines/500px.py')
-rw-r--r--searx/engines/500px.py63
1 files changed, 0 insertions, 63 deletions
diff --git a/searx/engines/500px.py b/searx/engines/500px.py
deleted file mode 100644
index f25678c24..000000000
--- a/searx/engines/500px.py
+++ /dev/null
@@ -1,63 +0,0 @@
-## 500px (Images)
-#
-# @website https://500px.com
-# @provide-api yes (https://developers.500px.com/)
-#
-# @using-api no
-# @results HTML
-# @stable no (HTML can change)
-# @parse url, title, thumbnail, img_src, content
-#
-# @todo rewrite to api
-
-
-from urllib import urlencode
-from urlparse import urljoin
-from lxml import html
-import re
-
-# engine dependent config
-categories = ['images']
-paging = True
-
-# search-url
-base_url = 'https://500px.com'
-search_url = base_url+'/search?search?page={pageno}&type=photos&{query}'
-
-
-# do search-request
-def request(query, params):
- params['url'] = search_url.format(pageno=params['pageno'],
- query=urlencode({'q': query}))
-
- return params
-
-
-# get response from search-request
-def response(resp):
- results = []
-
- dom = html.fromstring(resp.text)
- regex = re.compile('3\.jpg.*$')
-
- # parse results
- for result in dom.xpath('//div[@class="photo"]'):
- link = result.xpath('.//a')[0]
- url = urljoin(base_url, link.attrib.get('href'))
- title = result.xpath('.//div[@class="title"]//text()')[0]
- thumbnail_src = link.xpath('.//img')[0].attrib['src']
- # To have a bigger thumbnail, uncomment the next line
- #thumbnail_src = regex.sub('4.jpg', thumbnail_src)
- content = result.xpath('.//div[@class="info"]//text()')[0]
- img_src = regex.sub('2048.jpg', thumbnail_src)
-
- # append result
- results.append({'url': url,
- 'title': title,
- 'img_src': img_src,
- 'content': content,
- 'thumbnail_src': thumbnail_src,
- 'template': 'images.html'})
-
- # return results
- return results