fix: pass HTTP proxy env vars to Tencent Cloud SDK in sougou.py

The Tencent Cloud SDK (tencentcloud-sdk-python) does not automatically
read http_proxy/https_proxy environment variables, unlike the standard
requests library used by all other search providers. Without an explicit
HttpProfile.proxy setting, Sougou search bypasses the corporate proxy.

Fix: read proxy from all four env var variants and set HttpProfile.proxy
when a proxy is present, matching the pattern used in duckduckgo.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
imoes 2026-04-16 20:23:24 +02:00
parent cfca838549
commit 0c68d269a8

View file

@ -1,5 +1,6 @@
import logging
import json
import os
from typing import Optional, List
@ -27,6 +28,15 @@ def search_sougou(
cred = credential.Credential(sougou_api_sid, sougou_api_sk)
http_profile = HttpProfile()
http_profile.endpoint = 'tms.tencentcloudapi.com'
# Tencent Cloud SDK does not read proxy env vars automatically
proxy = (
os.environ.get("https_proxy")
or os.environ.get("HTTPS_PROXY")
or os.environ.get("http_proxy")
or os.environ.get("HTTP_PROXY")
)
if proxy:
http_profile.proxy = proxy
client_profile = ClientProfile()
client_profile.http_profile = http_profile
params = json.dumps({'Query': query, 'Cnt': 20})