SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
fix vimeo engine and add comments
Thomas Pointhuber58a443be29e9
diff --git a/searx/engines/vimeo.py b/searx/engines/vimeo.pyindex 94a6dd545..2a91e76fa 100644--- a/searx/engines/vimeo.py+++ b/searx/engines/vimeo.py@@ -1,43 +1,58 @@+## Vimeo (Videos)+#+# @website https://vimeo.com/+# @provide-api yes (http://developer.vimeo.com/api), they have a maximum count of queries/hour+#+# @using-api no (TODO, rewrite to api)+# @results HTML (using search portal)+# @stable no (HTML can change)+# @parse url, title, publishedDate, thumbnail+#+# @todo rewrite to api+# @todo set content-parameter with correct data+from urllib import urlencodefrom HTMLParser import HTMLParserfrom lxml import htmlfrom searx.engines.xpath import extract_textfrom dateutil import parser-base_url = 'http://vimeo.com'-search_url = base_url + '/search?{query}'-url_xpath = None-content_xpath = None-title_xpath = None-results_xpath = ''-content_tpl = '<a href="{0}"> <img src="{2}"/> </a>'-publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'+# engine dependent config+categories = ['videos']+paging = True-# the cookie set by vimeo contains all the following values,-# but only __utma seems to be requiered-cookie = {- #'vuid':'918282893.1027205400'- # 'ab_bs':'%7B%223%22%3A279%7D'- '__utma': '00000000.000#0000000.0000000000.0000000000.0000000000.0'- # '__utmb':'18302654.1.10.1388942090'- #, '__utmc':'18302654'- #, '__utmz':'18#302654.1388942090.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)' # noqa- #, '__utml':'search'-}+# search-url+base_url = 'https://vimeo.com'+search_url = base_url + '/search/page:{pageno}?{query}'++# specific xpath variables+url_xpath = './a/@href'+content_xpath = './a/img/@src'+title_xpath = './a/div[@class="data"]/p[@class="title"]/text()'+results_xpath = '//div[@id="browse_content"]/ol/li'+publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'+# do search-requestdef request(query, params):- params['url'] = search_url.format(query=urlencode({'q': query}))- params['cookies'] = cookie+ params['url'] = search_url.format(pageno=params['pageno'] ,+ query=urlencode({'q': query}))++ # TODO required?+ params['cookies']['__utma'] = '00000000.000#0000000.0000000000.0000000000.0000000000.0'+return params+# get response from search-requestdef response(resp):results = []+dom = html.fromstring(resp.text)p = HTMLParser()+ # parse resultsfor result in dom.xpath(results_xpath):url = base_url + result.xpath(url_xpath)[0]title = p.unescape(extract_text(result.xpath(title_xpath)))@@ -45,10 +60,13 @@ def response(resp):publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))+ # append resultresults.append({'url': url,'title': title,- 'content': content_tpl.format(url, title, thumbnail),+ 'content': '','template': 'videos.html','publishedDate': publishedDate,'thumbnail': thumbnail})++ # return resultsreturn resultsdiff --git a/searx/settings.yml b/searx/settings.ymlindex 3e1bb4fc7..6d398f871 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -153,11 +153,7 @@ engines:- name : vimeoengine : vimeo- categories : videos- results_xpath : //div[@id="browse_content"]/ol/li- url_xpath : ./a/@href- title_xpath : ./a/div[@class="data"]/p[@class="title"]/text()- content_xpath : ./a/img/@src+ locale : en-USshortcut : vmlocales: