Skip to content

Instantly share code, notes, and snippets.

@Nalisarc
Created January 19, 2016 00:26
Show Gist options
  • Save Nalisarc/8975c363194e2b704b20 to your computer and use it in GitHub Desktop.
Save Nalisarc/8975c363194e2b704b20 to your computer and use it in GitHub Desktop.
a test for checking if a site updates.
import requests
import time
timestamp = time.time()
timeformat = (time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(timestamp)))
url = 'http://stackoverflow.com/'
for x in range(100):
header = {'If-Modified-Since': timeformat}
r = requests.head(url, headers=header)
print r
#if response is 200:
#it updated
#If reponce is 304:
#it didn't
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment