Last active
June 12, 2017 06:49
-
-
Save hathehuyen/13731ad9189d1ff2513fa264f55204ba to your computer and use it in GitHub Desktop.
Check last modified time of an url using Last-Modified header
This file contains hidden or 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/python | |
from urllib2 import urlopen | |
from datetime import datetime | |
from rfc822 import parsedate_tz | |
# Check last modified time of an url using Last-Modified header | |
def check_last_modified(url): | |
u = urlopen(url) | |
meta = u.info() | |
last_modified = meta.getheaders("Last-Modified")[0] | |
# modified = datetime.strptime(last_modified, '%a, %d %b %Y %H:%M:%S GMT') | |
modified = datetime(*parsedate_tz(last_modified)[:7]) | |
return modified |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment