Skip to main content
 首页 » 编程设计

python之大量时间使用 suds 和代理发送数据

2025年05月04日6duanxz

我有以下代码使用 suds 通过代理发送数据:

 import suds 
 t = suds.transport.http.HttpTransport() 
 proxy = urllib2.ProxyHandler({'http': 'http://192.168.3.217:3128'}) 
 opener = urllib2.build_opener(proxy) 
 t.urlopener = opener 
 ws = suds.client.Client('http://xxxxxxx/web.asmx?WSDL', transport=t) 
 req = ws.factory.create('ActionRequest.request') 
 req.SerialNumber = 'asdf' 
 req.HostName = 'hola' 
 res = ws.service.ActionRequest(req) 

我不知道为什么,但它发送数据的时间可能超过 2 或 3 分钟,甚至更长,有时会引发“网关超时”异常。如果我不使用代理,则使用的时间超过 2 秒或更少。这是 SOAP 回复:

(ActionResponse){ 
   Id = None 
   Action = "Action.None" 
   Objects = "" 
 } 

代理通过 urllib2 或使用普通的网络浏览器(如 firefox)与其他请求一起运行。

有人知道这里的肥皂水是怎么回事吗?

提前致谢!!!

请您参考如下方法:

嗅探器输出(例如来自 wireshark)可能对理解这一点非常有帮助。