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
[mod] stackoverflow & yandex: detect CAPTCHA response
Alexandre Flamentfa909c7c024d
diff --git a/searx/engines/stackoverflow.py b/searx/engines/stackoverflow.pyindex c6d58de65..f730264e2 100644--- a/searx/engines/stackoverflow.py+++ b/searx/engines/stackoverflow.py@@ -10,9 +10,10 @@@parse url, title, content"""-from urllib.parse import urlencode, urljoin+from urllib.parse import urlencode, urljoin, urlparsefrom lxml import htmlfrom searx.utils import extract_text+from searx.exceptions import SearxEngineCaptchaException# engine dependent configcategories = ['it']@@ -37,6 +38,10 @@ def request(query, params):# get response from search-requestdef response(resp):+ resp_url = urlparse(resp.url)+ if resp_url.path.startswith('/nocaptcha'):+ raise SearxEngineCaptchaException()+results = []dom = html.fromstring(resp.text)diff --git a/searx/engines/yandex.py b/searx/engines/yandex.pyindex ff1ef5a26..b4a6a54cf 100644--- a/searx/engines/yandex.py+++ b/searx/engines/yandex.py@@ -9,9 +9,10 @@@parse url, title, content"""-from urllib.parse import urlencode+from urllib.parse import urlencode, urlparsefrom lxml import htmlfrom searx import logger+from searx.exceptions import SearxEngineCaptchaExceptionlogger = logger.getChild('yandex engine')@@ -47,6 +48,10 @@ def request(query, params):# get response from search-requestdef response(resp):+ resp_url = urlparse(resp.url)+ if resp_url.path.startswith('/showcaptcha'):+ raise SearxEngineCaptchaException()+dom = html.fromstring(resp.text)results = []