티스토리 뷰

공부

[Python] Content-Type & MIME-Type

승가비 2020. 5. 31. 12:00
728x90
import urllib.request
with urllib.request.urlopen('http://www.google.com') as response:
    info = response.info()
    print(info.get_content_type())      # -> text/html
    print(info.get_content_maintype())  # -> text
    print(info.get_content_subtype())   # -> html

https://stackoverflow.com/questions/12474406/python-how-to-get-the-content-type-of-an-url

 

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://www.iana....

stackoverflow.com

 

728x90
댓글