forked from Archives/searxng
parent
f2cbefeb54
commit
ab273e2faa
@ -27,11 +27,11 @@ base_url = 'https://vimeo.com'
|
|||||||
search_url = base_url + '/search/page:{pageno}?{query}'
|
search_url = base_url + '/search/page:{pageno}?{query}'
|
||||||
|
|
||||||
# specific xpath variables
|
# specific xpath variables
|
||||||
results_xpath = '//div[@id="browse_content"]/ol/li'
|
results_xpath = '//div[contains(@class,"results_grid")]/ul/li'
|
||||||
url_xpath = './a/@href'
|
url_xpath = './/a/@href'
|
||||||
title_xpath = './a/div[@class="data"]/p[@class="title"]'
|
title_xpath = './/span[@class="title"]'
|
||||||
content_xpath = './a/img/@src'
|
thumbnail_xpath = './/img[@class="js-clip_thumbnail_image"]/@src'
|
||||||
publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'
|
publishedDate_xpath = './/time/attribute::datetime'
|
||||||
|
|
||||||
embedded_url = '<iframe data-src="//player.vimeo.com/video{videoid}" ' +\
|
embedded_url = '<iframe data-src="//player.vimeo.com/video{videoid}" ' +\
|
||||||
'width="540" height="304" frameborder="0" ' +\
|
'width="540" height="304" frameborder="0" ' +\
|
||||||
@ -58,7 +58,7 @@ def response(resp):
|
|||||||
videoid = result.xpath(url_xpath)[0]
|
videoid = result.xpath(url_xpath)[0]
|
||||||
url = base_url + videoid
|
url = base_url + videoid
|
||||||
title = p.unescape(extract_text(result.xpath(title_xpath)))
|
title = p.unescape(extract_text(result.xpath(title_xpath)))
|
||||||
thumbnail = extract_text(result.xpath(content_xpath)[0])
|
thumbnail = extract_text(result.xpath(thumbnail_xpath)[0])
|
||||||
publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
|
publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
|
||||||
embedded = embedded_url.format(videoid=videoid)
|
embedded = embedded_url.format(videoid=videoid)
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import mock
|
import mock
|
||||||
from searx.engines import vimeo
|
from searx.engines import vimeo
|
||||||
@ -25,26 +26,42 @@ class TestVimeoEngine(SearxTestCase):
|
|||||||
self.assertEqual(vimeo.response(response), [])
|
self.assertEqual(vimeo.response(response), [])
|
||||||
|
|
||||||
html = """
|
html = """
|
||||||
<div id="browse_content" class="" data-search-id="696d5f8366914ec4ffec33cf7652de384976d4f4">
|
<div id="browse_content" class="results_grid" data-search-id="696d5f8366914ec4ffec33cf7652de384976d4f4">
|
||||||
<ol class="js-browse_list clearfix browse browse_videos browse_videos_thumbnails kane"
|
<ul class="js-browse_list clearfix browse browse_videos browse_videos_thumbnails kane"
|
||||||
data-stream="c2VhcmNoOjo6ZGVzYzp7InF1ZXJ5IjoidGVzdCJ9">
|
data-stream="c2VhcmNoOjo6ZGVzYzp7InF1ZXJ5IjoidGVzdCJ9">
|
||||||
<li id="clip_100785455" data-start-page="/search/page:1/sort:relevant/" data-position="1">
|
<li data-position="7" data-result-id="clip_79600943">
|
||||||
<a href="/videoid" title="Futurama 3d (test shot)">
|
<div class="clip_thumbnail">
|
||||||
<img src="http://image.url.webp"
|
<a href="/videoid" class="js-result_url">
|
||||||
srcset="http://i.vimeocdn.com/video/482375085_590x332.webp 2x" alt=""
|
<div class="thumbnail_wrapper">
|
||||||
class="thumbnail thumbnail_lg_wide">
|
<img src="http://image.url.webp" class="js-clip_thumbnail_image">
|
||||||
<div class="data">
|
<div class="overlay overlay_clip_meta">
|
||||||
<p class="title">
|
<div class="meta_data_footer">
|
||||||
This is the title
|
<span class="clip_upload_date">
|
||||||
</p>
|
<time datetime="2013-11-17T08:49:09-05:00"
|
||||||
<p class="meta">
|
title="dimanche 17 novembre 2013 08:49">Il y a 1 an</time>
|
||||||
<time datetime="2014-07-15T04:16:27-04:00"
|
</span>
|
||||||
title="mardi 15 juillet 2014 04:16">Il y a 6 mois</time>
|
<span class="clip_likes">
|
||||||
</p>
|
<img src="https://f.vimeocdn.com/images_v6/svg/heart-icon.svg">2 215
|
||||||
|
</span>
|
||||||
|
<span class="clip_comments">
|
||||||
|
<img src="https://f.vimeocdn.com/images_v6/svg/comment-icon.svg">75
|
||||||
|
</span>
|
||||||
|
<span class="overlay meta_data_footer clip_duration">01:12</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="title">This is the title</span>
|
||||||
</a>
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="clip_thumbnail_attribution">
|
||||||
|
<a href="/fedorshmidt">
|
||||||
|
<img src="https://i.vimeocdn.com/portrait/6628061_100x100.jpg" class="avatar">
|
||||||
|
<span class="display_name">Fedor Shmidt</span>
|
||||||
|
</a>
|
||||||
|
<span class="plays">2,1M lectures</span>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
response = mock.Mock(text=html)
|
response = mock.Mock(text=html)
|
||||||
|
Loading…
Reference in New Issue
Block a user