mirror of
https://github.com/searxng/searxng.git
synced 2025-12-28 14:40:02 +00:00
[enh] replace requests by httpx
This commit is contained in:
@@ -52,7 +52,7 @@ def response(resp):
|
||||
to_results.append(to_result.text_content())
|
||||
|
||||
results.append({
|
||||
'url': urljoin(resp.url, '?%d' % k),
|
||||
'url': urljoin(str(resp.url), '?%d' % k),
|
||||
'title': from_result.text_content(),
|
||||
'content': '; '.join(to_results)
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"""
|
||||
|
||||
from json import loads, dumps
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from searx.exceptions import SearxEngineAPIException
|
||||
|
||||
|
||||
@@ -32,7 +31,7 @@ def request(query, params):
|
||||
return params
|
||||
|
||||
if username and password:
|
||||
params['auth'] = HTTPBasicAuth(username, password)
|
||||
params['auth'] = (username, password)
|
||||
|
||||
params['url'] = search_url
|
||||
params['method'] = 'GET'
|
||||
|
||||
@@ -10,7 +10,7 @@ Definitions`_.
|
||||
|
||||
# pylint: disable=invalid-name, missing-function-docstring
|
||||
|
||||
from urllib.parse import urlencode, urlparse
|
||||
from urllib.parse import urlencode
|
||||
from lxml import html
|
||||
from searx import logger
|
||||
from searx.utils import match_language, extract_text, eval_xpath, eval_xpath_list, eval_xpath_getindex
|
||||
@@ -186,8 +186,7 @@ def get_lang_info(params, lang_list, custom_aliases):
|
||||
return ret_val
|
||||
|
||||
def detect_google_sorry(resp):
|
||||
resp_url = urlparse(resp.url)
|
||||
if resp_url.netloc == 'sorry.google.com' or resp_url.path.startswith('/sorry'):
|
||||
if resp.url.host == 'sorry.google.com' or resp.url.path.startswith('/sorry'):
|
||||
raise SearxEngineCaptchaException()
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Seznam
|
||||
"""
|
||||
|
||||
from urllib.parse import urlencode, urlparse
|
||||
from urllib.parse import urlencode
|
||||
from lxml import html
|
||||
from searx.poolrequests import get
|
||||
from searx.exceptions import SearxEngineAccessDeniedException
|
||||
@@ -46,8 +46,7 @@ def request(query, params):
|
||||
|
||||
|
||||
def response(resp):
|
||||
resp_url = urlparse(resp.url)
|
||||
if resp_url.path.startswith('/verify'):
|
||||
if resp.url.path.startswith('/verify'):
|
||||
raise SearxEngineAccessDeniedException()
|
||||
|
||||
results = []
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
from json import loads
|
||||
from urllib.parse import urlencode
|
||||
import requests
|
||||
import searx.poolrequests as requests
|
||||
import base64
|
||||
|
||||
# about
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Stackoverflow (IT)
|
||||
"""
|
||||
|
||||
from urllib.parse import urlencode, urljoin, urlparse
|
||||
from urllib.parse import urlencode, urljoin
|
||||
from lxml import html
|
||||
from searx.utils import extract_text
|
||||
from searx.exceptions import SearxEngineCaptchaException
|
||||
@@ -41,8 +41,7 @@ def request(query, params):
|
||||
|
||||
# get response from search-request
|
||||
def response(resp):
|
||||
resp_url = urlparse(resp.url)
|
||||
if resp_url.path.startswith('/nocaptcha'):
|
||||
if resp.url.path.startswith('/nocaptcha'):
|
||||
raise SearxEngineCaptchaException()
|
||||
|
||||
results = []
|
||||
|
||||
@@ -7,7 +7,7 @@ from json import loads
|
||||
from dateutil import parser
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from requests.auth import HTTPDigestAuth
|
||||
from httpx import DigestAuth
|
||||
|
||||
from searx.utils import html_to_text
|
||||
|
||||
@@ -56,7 +56,7 @@ def request(query, params):
|
||||
search_type=search_type)
|
||||
|
||||
if http_digest_auth_user and http_digest_auth_pass:
|
||||
params['auth'] = HTTPDigestAuth(http_digest_auth_user, http_digest_auth_pass)
|
||||
params['auth'] = DigestAuth(http_digest_auth_user, http_digest_auth_pass)
|
||||
|
||||
# add language tag if specified
|
||||
if params['language'] != 'all':
|
||||
|
||||
Reference in New Issue
Block a user