Skip to content

Instantly share code, notes, and snippets.

@hathehuyen
Last active June 12, 2017 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hathehuyen/13731ad9189d1ff2513fa264f55204ba to your computer and use it in GitHub Desktop.
Save hathehuyen/13731ad9189d1ff2513fa264f55204ba to your computer and use it in GitHub Desktop.
Check last modified time of an url using Last-Modified header
#!/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