how to check the 'content/type' using urlopen

John Allerdyce.John at gmail.com
Mon Apr 16 01:25:23 CEST 2007


i have the following code to open a URL address, but can you please
tell me how can I check the content type of the url response?

Thank you.

  try:
        req = Request(url, txdata, txheaders)
        handle = urlopen(req)
    except IOError, e:
        print e
        print 'Failed to open %s' % url
        return 0;

    else:
        data = handle.read()




More information about the Python-list mailing list