mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-05-09 03:57:43 +08:00
适配没有redisKeys和快代理没有账号密码的情况
Co-Authored-By: ouzhuowei <190020754@qq.com>
This commit is contained in:
@@ -180,11 +180,19 @@ def format_proxy_info(ip_proxy_info) -> Tuple[Optional[Dict], Optional[str]]:
|
||||
from proxy.proxy_ip_pool import IpInfoModel
|
||||
ip_proxy_info = cast(IpInfoModel, ip_proxy_info)
|
||||
|
||||
# Playwright proxy server should be in format "host:port" without protocol prefix
|
||||
# Remove protocol prefix if present (http:// or https://)
|
||||
server = f"{ip_proxy_info.ip}:{ip_proxy_info.port}"
|
||||
|
||||
playwright_proxy = {
|
||||
"server": f"{ip_proxy_info.protocol}{ip_proxy_info.ip}:{ip_proxy_info.port}",
|
||||
"username": ip_proxy_info.user,
|
||||
"password": ip_proxy_info.password,
|
||||
"server": server,
|
||||
}
|
||||
|
||||
# Only add username and password if they are not empty
|
||||
if ip_proxy_info.user and ip_proxy_info.password:
|
||||
playwright_proxy["username"] = ip_proxy_info.user
|
||||
playwright_proxy["password"] = ip_proxy_info.password
|
||||
|
||||
# httpx 0.28.1 requires passing proxy URL string directly, not a dictionary
|
||||
if ip_proxy_info.user and ip_proxy_info.password:
|
||||
httpx_proxy = f"http://{ip_proxy_info.user}:{ip_proxy_info.password}@{ip_proxy_info.ip}:{ip_proxy_info.port}"
|
||||
|
||||
Reference in New Issue
Block a user