Python论坛  - 讨论区

标题:[python-chinese] 如何发送正确的http请求下载文件

2007年01月30日 星期二 09:48

wxt1984 wxt1984在163.com
星期二 一月 30 09:48:30 HKT 2007

Hi All
import httplibconn = httplib.HTTPConnection("http://www.sugarcane.xmublog.com:80")conn.set_debuglevel(1)conn.putrequest('GET','/UploadFiles/2006-8/830935836.mp3',False,True)conn.putheader('Accept',"*/*")conn.putheader('Connection',"close")conn.endheaders()rMsg = conn.getresponse()这段代码总是返回HTTP 400错误 显示请求语法有问题,本人对http协议了解不深,望高手赐教,不胜感激
Best Regard and Thanks 
-------------- 涓嬩竴閮ㄥ垎 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20070130/51d17fcd/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年01月30日 星期二 10:10

Hong Yuan hongyuan在homemaster.cn
星期二 一月 30 10:10:53 HKT 2007

*class HTTPConnection*( 	host[, port])

    An HTTPConnection instance represents one transaction with an HTTP
    server. It should be instantiated passing it a host and optional
    port number. If no port number is passed, the port is extracted from
    the host string if it has the form |host:port|, else the default
    HTTP port (80) is used. For example, the following calls all create
    instances that connect to the server at the same host and port:

    >>> h1 = httplib.HTTPConnection('www.cwi.nl')
    >>> h2 = httplib.HTTPConnection('www.cwi.nl:80')
    >>> h3 = httplib.HTTPConnection('www.cwi.nl', 80)
        

ÒÔÉÏΪPython ManualµÄÄÚÈÝ¡£Ó¦¸ÃHTTPConnectionºó²»ÓÃÔÚÊäÈëЭÒé'http://'ÁË°É¡£

wxt1984 дµÀ:
> Hi All
>
> import httplib
> conn = httplib.HTTPConnection("http://www.sugarcane.xmublog.com:80")
> conn.set_debuglevel(1)
> conn.putrequest('GET','/UploadFiles/2006-8/830935836.mp3',False,True)
> conn.putheader('Accept',"*/*")
> conn.putheader('Connection',"close")
> conn.endheaders()
> rMsg = conn.getresponse()
> Õâ¶Î´úÂë×ÜÊÇ·µ»ØHTTP 400´íÎó ÏÔʾÇëÇóÓï·¨ÓÐÎÊÌ⣬±¾È˶ÔhttpЭÒéÁ˽ⲻ 
> ÉÍû¸ßÊִͽ̣¬²»Ê¤¸Ð¼¤
>
> Best Regard and Thanks
>
>
> ------------------------------------------------------------------------
> Å®ÓÑϲ»¶È¥µÄºÃµØ·½!ËùÓ櫶«ÍÂѪ¼Û µã»÷½øÈëÓдó¾ªÏ²! 
> <http://adtaobao.allyes.com/main/adfclick?db=adtaobao&bid;=1319,1299,145&cid;=29985,198,1&sid;=45085&show;=ignore&url;=http://www.taobao.com/vertical/mall/pro.php> 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


-- 

´ó¹Ü¼ÒÍøÉϽ¨²Ä³¬ÊÐ
×°ÐÞÂò½¨²Ä ÉÏÍøÕÒ´ó¹Ü¼Ò
http://www.homemaster.cn
Tel: 0086-21-34240987
Fax: 0086-21-64692422


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号