Created
January 19, 2016 00:26
-
-
Save Nalisarc/8975c363194e2b704b20 to your computer and use it in GitHub Desktop.
a test for checking if a site updates.
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
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