summaryrefslogtreecommitdiff
path: root/searx/engines/google_videos.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-11-26 17:22:54 +0100
committerAlexandre Flament <alex@al-f.net>2020-12-03 10:22:48 +0100
commit64cccae99e625f3ebd879f94797decd0d824608d (patch)
tree7ef098d4630c5416aad58f0d3ce5abb27390423f /searx/engines/google_videos.py
parentad72803ed98760b2a95690dea3b95eacc670427c (diff)
downloadsearxng-64cccae99e625f3ebd879f94797decd0d824608d.tar.gz
searxng-64cccae99e625f3ebd879f94797decd0d824608d.zip
[mod] various engines: use eval_xpath* functions and searx.exceptions.*
Engine list: ahmia, duckduckgo_images, elasticsearch, google, google_images, google_videos, youtube_api
Diffstat (limited to 'searx/engines/google_videos.py')
-rw-r--r--searx/engines/google_videos.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/searx/engines/google_videos.py b/searx/engines/google_videos.py
index 1e6c8b3ee..eedefbf45 100644
--- a/searx/engines/google_videos.py
+++ b/searx/engines/google_videos.py
@@ -13,7 +13,7 @@
from datetime import date, timedelta
from urllib.parse import urlencode
from lxml import html
-from searx.utils import extract_text
+from searx.utils import extract_text, eval_xpath, eval_xpath_list, eval_xpath_getindex
import re
# engine dependent config
@@ -66,11 +66,11 @@ def response(resp):
dom = html.fromstring(resp.text)
# parse results
- for result in dom.xpath('//div[@class="g"]'):
+ for result in eval_xpath_list(dom, '//div[@class="g"]'):
- title = extract_text(result.xpath('.//h3'))
- url = result.xpath('.//div[@class="r"]/a/@href')[0]
- content = extract_text(result.xpath('.//span[@class="st"]'))
+ title = extract_text(eval_xpath(result, './/h3'))
+ url = eval_xpath_getindex(result, './/div[@class="r"]/a/@href', 0)
+ content = extract_text(eval_xpath(result, './/span[@class="st"]'))
# get thumbnails
script = str(dom.xpath('//script[contains(., "_setImagesSrc")]')[0].text)