Python论坛  - 讨论区

标题:[python-chinese] 向HTTP服务器发送post请求时老是显示BadStatusLine

2007年01月20日 星期六 23:22

qi wang hk.wangqi在gmail.com
星期六 一月 20 23:22:14 HKT 2007

´ó¼ÒºÃ£º


ÎÒżȻ¿´¼ûÁËһƪ¹ØÓÚQQµÄHTTP½Ó¿ÚµÄÌû×Ó£¨
http://blog.hackfan.net£©£¬´ÓÉÏÃæÁ˽⵽ÁËQQÓÐÒ»¸öÖ§³Öpost·½Ê½µÄ½Ó¿Ú¡£ÓÚÊÇÏëÓÃpythonÀ´ÊµÏÖ¡£ÎÒ¶Ôpost·½·¨ºÍpythonµÄHTTPÄ£¿é¶¼²»Ì«Á˽⡣ÔÚÍøÉÏÕÒÁË°ëÌìҲûÕÒµ½ÏëÒªµÄÖÐÎÄ×ÊÁÏ£¬Ö»ºÃÈ¥¿´python¸½´øµÄÓ¢ÎÄÎĵµ¡£ÎÒÓ¢ÎÄʵÔÚÌ«²î£¬°ë²Â°ëÊÔµÄŪÁ˺þö¼Ã»Óгɹ¦¡£Ï£Íû´ó¼ÒÄܸøµã°ïÖú»òÌáʾ¡££¨ÏÂÃæÊǽӿڵļò½éºÍÎÒдµÄ´úÂ룩

½Ó¿Ú˵Ã÷£º

½Ó¿ÚλÖãºtqq.tencent.com:8000
ͨÐÅЭÒ飺HTTP
Êý¾Ý´«Êä·½·¨£ºPOST
HTTPÇëÇó¸ñʽ£º

POST HTTP/1.1
Host: tqq.tencent.com:8000
Content-Type: text/plain; charset=UTF-8
Content-length: ³¤¶È
Connection: close

Êý¾Ý

ÆäÖ㤶ÈΪ Êý¾Ý µÄ³¤¶È£¬Êý¾ÝµÄ¸ñʽ£º
VER=1.1&CMD;=ÃüÁî&SEQ;=±ê¼Ç&UIN;=QQºÅ&....£¨ÏêϸµÄ½éÉÜÇëµ½Ô­Ìûhttp://blog.hackfan.netÉϲ鿴£©

ÕâÊÇÎÒдµÄ´úÂë

import httplib
import md5
import random

mm = md5.new("(ÎÒQQºÅµÄÃÜÂëÕâÀï¾Í²»Ð´³öÀ´ÁË£©").digest()

body = "VER=1.1&CMD;=Login&SEQ;="+str(random.randint
(1000,9000))+"&UIN;=727524368&PS;="+mm+"&M5;=1&LC;=9326B87B234E7235"

q = httplib.HTTPConnection("tqq.tencent.com:8000")
q.putrequest("POST","HTTP/1.1")
q.putheader("Content-Type","text/plain;charset=UTF-8")
q.putheader("Content-length",str(len(body)))
q.endheaders()
q.send(body)

re = q.getresponse()


ÔËÐнá¹û
>>>

Traceback (most recent call last):
  File "H:\Python25\shiyan.py", line 18, in 
    re = q.getresponse()
  File "H:\Python25\lib\httplib.py", line 924, in getresponse
    response.begin()
  File "H:\Python25\lib\httplib.py", line 385, in begin
    version, status, reason = self._read_status()
  File "H:\Python25\lib\httplib.py", line 349, in _read_status
    raise BadStatusLine(line)
BadStatusLine
>>>


Íõçù
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070120/6b299034/attachment.html 

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

2007年01月21日 星期日 00:36

kuafoo lovegroups在gmail.com
星期日 一月 21 00:36:40 HKT 2007

Õâ¸ö½Ó¿ÚºÃÏñÔç¾Í²»ÄÜÓÃÁË°É

ÔÚ07-1-20£¬qi wang <hk.wangqi在gmail.com> дµÀ£º
>
> ´ó¼ÒºÃ£º
>
>
> ÎÒżȻ¿´¼ûÁËһƪ¹ØÓÚQQµÄHTTP½Ó¿ÚµÄÌû×Ó£¨http://blog.hackfan.net£©£¬´ÓÉÏÃæÁ˽⵽ÁËQQÓÐÒ»¸öÖ§³Öpost·½Ê½µÄ½Ó¿Ú¡£ÓÚÊÇÏëÓÃpythonÀ´ÊµÏÖ¡£ÎÒ¶Ôpost·½·¨ºÍpythonµÄHTTPÄ£¿é¶¼²»Ì«Á˽⡣ÔÚÍøÉÏÕÒÁË°ëÌìҲûÕÒµ½ÏëÒªµÄÖÐÎÄ×ÊÁÏ£¬Ö»ºÃÈ¥¿´python¸½´øµÄÓ¢ÎÄÎĵµ¡£ÎÒÓ¢ÎÄʵÔÚÌ«²î£¬°ë²Â°ëÊÔµÄŪÁ˺þö¼Ã»Óгɹ¦¡£Ï£Íû´ó¼ÒÄܸøµã°ïÖú»òÌáʾ¡££¨ÏÂÃæÊǽӿڵļò½éºÍÎÒдµÄ´úÂ룩>
>
> ½Ó¿Ú˵Ã÷£º
>
> ½Ó¿ÚλÖ㺠tqq.tencent.com:8000
> ͨÐÅЭÒ飺HTTP
> Êý¾Ý´«Êä·½·¨£ºPOST
> HTTPÇëÇó¸ñʽ£º
>
> POST HTTP/1.1
> Host: tqq.tencent.com:8000
> Content-Type: text/plain; charset=UTF-8
> Content-length: ³¤¶È
> Connection: close
>
> Êý¾Ý
>
> ÆäÖ㤶ÈΪ Êý¾Ý µÄ³¤¶È£¬Êý¾ÝµÄ¸ñʽ£º
> VER=1.1&CMD;=ÃüÁî&SEQ;=±ê¼Ç&UIN;=QQºÅ&....£¨ÏêϸµÄ½éÉÜÇëµ½Ô­Ìûhttp://blog.hackfan.netÉϲ鿴£©>
>
> ÕâÊÇÎÒдµÄ´úÂë
>
> import httplib
> import md5
> import random
>
> mm = md5.new("(ÎÒQQºÅµÄÃÜÂëÕâÀï¾Í²»Ð´³öÀ´ÁË£©").digest()
>
> body = "VER=1.1&CMD;=Login&SEQ;="+str(random.randint(1000,9000))+"&UIN;=727524368&PS;="+mm+"&M5;=1&LC;=9326B87B234E7235"
>
>
> q = httplib.HTTPConnection("tqq.tencent.com:8000")
> q.putrequest("POST","HTTP/1.1")
> q.putheader("Content-Type","text/plain;charset=UTF-8")
> q.putheader("Content-length",str(len(body)))
> q.endheaders()
> q.send(body)
>
> re = q.getresponse()
>
>
> ÔËÐнá¹û
> >>>
>
> Traceback (most recent call last):
>   File "H:\Python25\shiyan.py", line 18, in 
>     re = q.getresponse()
>   File "H:\Python25\lib\httplib.py", line 924, in getresponse
>     response.begin()
>   File "H:\Python25\lib\httplib.py", line 385, in begin
>     version, status, reason = self._read_status()
>   File "H:\Python25\lib\httplib.py", line 349, in _read_status
>     raise BadStatusLine(line)
> BadStatusLine
> >>>
>
>
> Íõçù
>
> _______________________________________________
> 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
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070121/4b769480/attachment-0001.htm 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号