test-http.py 239 B

1234567891011
  1. import urllib2
  2. request = urllib2.Request("http://google.com/")
  3. opener = urllib2.build_opener()
  4. response = opener.open(request, timeout=10)
  5. while True:
  6. data = response.read(1024)
  7. if data:
  8. print data
  9. else:
  10. break