Created
October 15, 2016 18:17
-
-
Save sudokode/414930a9188d2550bc27b98b0008f87d to your computer and use it in GitHub Desktop.
content-type in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import re | |
import requests as r | |
urls = sys.argv[1:] | |
for url in urls: | |
if not re.match('^http(s)?://', url): | |
url = 'http://' + url | |
response = r.get(url, allow_redirects=True) | |
if response: | |
if response.headers['content-type']: | |
print('{} is {}'.format(url, response.headers['content-type'])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment