2007年05月01日 星期二 13:01
> > 最近做个小东西,使用urllib2和httplib发送http post请求,但是要求使用http1.0协 > 议。httplib里面写死的是1.1。请教有其它方法吗? 使用 1.0 发送请求: import httplib import urllib2 class HTTPConnection10(httplib.HTTPConnection): _http_vsn = 10 _http_vsn_str = 'HTTP/1.0' class HTTPHandler10(urllib2.HTTPHandler): def http_open(self, req): return self.do_open(HTTPConnection10, req) urllib2._opener = urllib2.build_opener(HTTPHandler10(1)) fd = urllib2.urlopen('http://www.google.com') print 'data:\n', fd.read() 建议:没有文档的时候可以稍微看下代码。 -- http://codeplayer.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070501/d29d1390/attachment.html
Zeuux © 2025
京ICP备05028076号