Eduard Florinescu Eduard Florinescu - 9 months ago 23
Python Question

Python: How to get the Content-Type of an URL?

I need to get the content-type of an internet(intranet) resource not a local file. How can I get the MIME type from a resource behind an URL:

I tried this:

res = urllib.urlopen("")
http_message =
message = http_message.getplist()

I get:

How can I get the
, can be done using
and how or if not what is the other way?

res = urllib.urlopen("" )
http_message =
full = http_message.type # 'text/plain'
main = http_message.maintype # 'text'