Python论坛  - 讨论区

标题:Re: Re: [python-chinese] 读取http页面耗时的问题

2006年03月21日 星期二 11:33

charles huang hyy at fjii.com
Tue Mar 21 11:33:25 HKT 2006

limodou,您好!

	应该没问题啊,后面还有加上这些代码啊:

	        response_ob = conn.getresponse()
            if response_ob.reason == 'OK':
                self.stc.svc_stat = 'OK'
                time_begin = time.time()
                page_len = len(response_ob.read())
                time_end = time.time()
                time_cost = time_cost + round(time_end - time_begin, 4)
                break
            else:


======= 2006-03-21 11:26:17 您在来信中写道:=======

>On 3/21/06, charles huang <hyy at fjii.com> wrote:
>> python-chinese,您好!
>>       写了一段代码,来get一个页面,并计算所耗的时间,可发现每次读取页面所耗的时间都只有零点几秒,有的甚至只有零点零几秒,都怀疑是不是有cache,可httplib的文档里面好像没有提到这点,代码如下:
>>
>>         conn = httplib.HTTPConnection('www.some-domain-name.com')
>>         for j in xrange(3):
>>             try:
>>                 time_begin = time.time()
>>                 conn.request("GET",'/index.htm')
>>                 time_end = time.time()
>>                 time_cost = round(time_end - time_begin, 4)
>>                 except:
>>                 time.sleep(2)
>>                 continue
>>
>>
>
>建议你看一下得到的内容,是不是出错了。
>
>--
>I like python!
>My Blog: http://www.donews.net/limodou
>NewEdit Maillist: http://groups.google.com/group/NewEdit
>_______________________________________________
>python-chinese
>Post: send python-chinese at lists.python.cn
>Subscribe: send subscribe to python-chinese-request at lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        charles huang
        hyy at fjii.com
			   TEL: 0591-3333169-212
          2006-03-21


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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号