2 # -*- coding: iso-8859-1 -*-
8 from cStringIO import StringIO
10 from StringIO import StringIO
15 "http://curl.haxx.se",
16 "http://www.python.org",
17 "http://pycurl.sourceforge.net",
18 "http://pycurl.sourceforge.net/tests/403_FORBIDDEN", # that actually exists ;-)
19 "http://pycurl.sourceforge.net/tests/404_NOT_FOUND",
22 # Read list of URIs from file specified on commandline
24 urls = open(sys.argv[1], "rb").readlines()
26 # No file was specified
30 m = pycurl.CurlMulti()
34 # save info in standard Python attributes
40 c.setopt(c.URL, c.url)
41 c.setopt(c.WRITEFUNCTION, c.body.write)
45 num_handles = len(m.handles)
48 ret, num_handles = m.perform()
49 if ret != pycurl.E_CALL_MULTI_PERFORM:
51 # currently no more I/O is pending, could do something in the meantime
52 # (display a progress bar, etc.)
57 # save info in standard Python attributes
58 c.http_code = c.getinfo(c.HTTP_CODE)
66 data = c.body.getvalue()
68 print "**********", c.url, "**********"
71 print "%-53s http_code %3d, %6d bytes" % (c.url, c.http_code, len(data))