Eduard Florinescu Eduard Florinescu - 2 years ago 140
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?

Answer Source
res = urllib.urlopen("" )
http_message =
full = http_message.type # 'text/plain'
main = http_message.maintype # 'text'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download