I am requesting ulrs using the requests package in python (e.g. file = requests.get(url)). The urls do not specify an extension in them, and sometimes a html file is returned and sometimes a pdf is returned.
Is there a way of determining if the returned file is a pdf or a html? (or more generally, what the file format is). The browser is able to determine, so I assume must be indicate in the response.
This will be found in the
Content-Type
header, eithertext/html
orapplication/pdf