1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-05 04:40:11 +01:00

Merge pull request #614 from return42/pylint-bing-video

[pylint] Bing (Videos) engine
This commit is contained in:
Markus Heiser 2021-12-29 09:30:10 +01:00 committed by GitHub
commit 5cbbdc305f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,14 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
""" # lint: pylint
Bing (Videos) """Bing (Videos)
""" """
from json import loads from json import loads
from lxml import html
from urllib.parse import urlencode from urllib.parse import urlencode
from lxml import html
from searx.utils import match_language from searx.utils import match_language
from searx.engines.bing import language_aliases from searx.engines.bing import language_aliases
@ -82,22 +84,18 @@ def response(resp):
dom = html.fromstring(resp.text) dom = html.fromstring(resp.text)
for result in dom.xpath('//div[@class="dg_u"]'): for result in dom.xpath('//div[@class="dg_u"]'):
try: metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0])
metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0]) info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip()
info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip() content = '{0} - {1}'.format(metadata['du'], info)
content = '{0} - {1}'.format(metadata['du'], info) thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid'])
thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid']) results.append(
results.append( {
{ 'url': metadata['murl'],
'url': metadata['murl'], 'thumbnail': thumbnail,
'thumbnail': thumbnail, 'title': metadata.get('vt', ''),
'title': metadata.get('vt', ''), 'content': content,
'content': content, 'template': 'videos.html',
'template': 'videos.html', }
} )
)
except:
continue
return results return results