bnblazer
asked on
urllib2 info()
Sorry if this is a stupid question, but I am a bit stuck. I am using info() from urllib2. It returns the metadata of the url. I would like to print 'some' of this info to the screen, but I can't seem to get just what I want. I would like to avoid re, but am prepared to use it if needed.
For example. Calling info() on cnn.com produces this output:
ate: Sat, 04 Nov 2006 00:01:09 GMT
Server: Apache
Vary: Accept-Encoding,User-Agent
Cache-Control: max-age=60, private
Expires: Sat, 04 Nov 2006 00:02:01 GMT
Content-Type: text/html
Content-Length: 103933
Connection: close
How would I just get parts of it? For example, just the Server and content-type. Or the content length, expiration and ate? I believe that info() returns a dict, but I am not sure.
Thanks,
Brian
For example. Calling info() on cnn.com produces this output:
ate: Sat, 04 Nov 2006 00:01:09 GMT
Server: Apache
Vary: Accept-Encoding,User-Agent
Cache-Control: max-age=60, private
Expires: Sat, 04 Nov 2006 00:02:01 GMT
Content-Type: text/html
Content-Length: 103933
Connection: close
How would I just get parts of it? For example, just the Server and content-type. Or the content length, expiration and ate? I believe that info() returns a dict, but I am not sure.
Thanks,
Brian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brian