diff options
author | Adam Tauber <asciimoo@gmail.com> | 2018-02-11 01:01:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-11 01:01:01 +0100 |
commit | 360f8fab97a364e2f5e7fc8c5329cccb1ad5654a (patch) | |
tree | fcbcadad187b73b92654338039c4e858cc1d4f28 /searx/engines/bing_videos.py | |
parent | ccc6955f0c3796347cc32755b82afdf7a1c53a79 (diff) | |
parent | 3ef8533f4d402457808e9d9fb52af982abb8112f (diff) | |
download | searxng-360f8fab97a364e2f5e7fc8c5329cccb1ad5654a.tar.gz searxng-360f8fab97a364e2f5e7fc8c5329cccb1ad5654a.zip |
Merge pull request #1186 from kvch/fix-bing-videos
Fix Bing videos engine
Diffstat (limited to 'searx/engines/bing_videos.py')
-rw-r--r-- | searx/engines/bing_videos.py | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py index bd91bce37..312a82ba1 100644 --- a/searx/engines/bing_videos.py +++ b/searx/engines/bing_videos.py @@ -69,22 +69,11 @@ def response(resp): dom = html.fromstring(resp.text) for result in dom.xpath('//div[@class="dg_u"]'): - - # try to extract the url - url_container = result.xpath('.//div[@class="sa_wrapper"]/@data-eventpayload') - if len(url_container) > 0: - url = loads(url_container[0])['purl'] - else: - url = result.xpath('./a/@href')[0] - - # discard results that do not return an external url - # very recent results sometimes don't return the video's url - if url.startswith('/videos/search?'): - continue - - title = extract_text(result.xpath('./a//div[@class="tl"]')) - content = extract_text(result.xpath('.//div[@class="pubInfo"]')) - thumbnail = result.xpath('.//div[@class="vthumb"]/img/@src')[0] + url = result.xpath('./div[@class="mc_vtvc"]/a/@href')[0] + url = 'https://bing.com' + url + title = extract_text(result.xpath('./div/a/div/div[@class="mc_vtvc_title"]/@title')) + content = extract_text(result.xpath('./div/a/div/div/div/div/text()')) + thumbnail = result.xpath('./div/a/div/div/img/@src')[0] results.append({'url': url, 'title': title, @@ -92,7 +81,6 @@ def response(resp): 'thumbnail': thumbnail, 'template': 'videos.html'}) - # first page ignores requested number of results if len(results) >= number_of_results: break |