summaryrefslogtreecommitdiff
path: root/searx/engines/stackoverflow.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-12-03 13:23:19 +0100
committerAlexandre Flament <alex@al-f.net>2020-12-03 13:23:19 +0100
commitfa909c7c024d9ec98f6611fde0f99b0e797b1f3b (patch)
tree00793b129b8e3cd80a5feee1224c270687c40cae /searx/engines/stackoverflow.py
parent7905d4148718816de60cafff8a05ce95f97ce6aa (diff)
downloadsearxng-fa909c7c024d9ec98f6611fde0f99b0e797b1f3b.tar.gz
searxng-fa909c7c024d9ec98f6611fde0f99b0e797b1f3b.zip
[mod] stackoverflow & yandex: detect CAPTCHA response
Diffstat (limited to 'searx/engines/stackoverflow.py')
-rw-r--r--searx/engines/stackoverflow.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/searx/engines/stackoverflow.py b/searx/engines/stackoverflow.py
index 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, urlparse
from lxml import html
from searx.utils import extract_text
+from searx.exceptions import SearxEngineCaptchaException
# engine dependent config
categories = ['it']
@@ -37,6 +38,10 @@ def request(query, params):
# get response from search-request
def response(resp):
+ resp_url = urlparse(resp.url)
+ if resp_url.path.startswith('/nocaptcha'):
+ raise SearxEngineCaptchaException()
+
results = []
dom = html.fromstring(resp.text)