How to test if a webpage is an image python requests 1

How to test if a webpage is an image python requests

import requests
response = requests.head(url)
print response.headers.get('content-type')

Here is what the above code is Doing:
1. We import the requests module.
2. We make a HEAD request to the URL.
3. We print the value of the Content-Type header.

Similar Posts