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] yahoo url extraction
Adam Tauber0fc481f47ed8
diff --git a/searx/engines/yahoo.py b/searx/engines/yahoo.pyindex f070b8a7d..a6c597e1c 100644--- a/searx/engines/yahoo.py+++ b/searx/engines/yahoo.py@@ -15,6 +15,10 @@ suggestion_xpath = '//div[@id="satat"]//a'paging = True+def parse_url(url_string):+ start = url_string.find('http', url_string.find('/RU=')+1)+ end = min(url_string.rfind('/RS'), url_string.rfind('/RK'))+ return unquote(url_string[start:end])def request(query, params):offset = (params['pageno'] - 1) * 10 + 1@@ -34,10 +38,7 @@ def response(resp):dom = html.fromstring(resp.text)for result in dom.xpath(results_xpath):- url_string = extract_url(result.xpath(url_xpath), search_url)- start = url_string.find('http', url_string.find('/RU=')+1)- end = url_string.rfind('/RS')- url = unquote(url_string[start:end])+ url = parse_url(extract_url(result.xpath(url_xpath), search_url))title = extract_text(result.xpath(title_xpath)[0])content = extract_text(result.xpath(content_xpath)[0])results.append({'url': url, 'title': title, 'content': content})diff --git a/searx/engines/yahoo_news.py b/searx/engines/yahoo_news.pyindex 3c257866c..35e323917 100644--- a/searx/engines/yahoo_news.py+++ b/searx/engines/yahoo_news.py@@ -1,9 +1,9 @@#!/usr/bin/env pythonfrom urllib import urlencode-from urlparse import unquotefrom lxml import htmlfrom searx.engines.xpath import extract_text, extract_url+from searx.engines.yahoo import parse_urlcategories = ['news']search_url = 'http://news.search.yahoo.com/search?{query}&b={offset}'@@ -34,10 +34,7 @@ def response(resp):dom = html.fromstring(resp.text)for result in dom.xpath(results_xpath):- url_string = extract_url(result.xpath(url_xpath), search_url)- start = url_string.find('http', url_string.find('/RU=')+1)- end = url_string.rfind('/RS')- url = unquote(url_string[start:end])+ url = parse_url(extract_url(result.xpath(url_xpath), search_url))title = extract_text(result.xpath(title_xpath)[0])content = extract_text(result.xpath(content_xpath)[0])results.append({'url': url, 'title': title, 'content': content})