timing a web response using urllib.urlopen??
Cousin Stanley
CousinStanley at hotmail.com
Wed Dec 31 12:36:43 EST 2003
| i'm trying to open an array of websites,
| timing each site's response time
| ( how may seconds until a response )
|
| if someone could point me in the right direction
| on accomplishing the timer part of the this application,
| i'd appreciate it.
'''
NewsGroup .... comp.lang.python
Date ......... 2003-04-30
Posted_By .... kkennedy
Edited_By .... Stanley C. Kitching
'''
from urllib import urlopen
import sys
import time
print '\n ' , sys.argv[ 0 ] , '\n'
list_urls = [ 'http://www.python.org' ,
'http://www.ibm.com' ,
'http://www.microsoft.com' ,
'http://www.sun.com' , ]
for this_url in list_urls :
start = time.time()
doc = urlopen( this_url ).read()
end = time.time()
print " %0.2f .... %s" % ( end - start , this_url )
#
# ------------------------------------------------------------
#
# Output ....
#
url_open_test.py
2.64 .... http://www.python.org
1.10 .... http://www.ibm.com
0.71 .... http://www.microsoft.com
0.66 .... http://www.sun.com
--
Cousin Stanley
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list