Skip to content

Instantly share code, notes, and snippets.

@barca
Created May 1, 2020 23:29
Show Gist options
  • Save barca/6e9044ceb717b53f7839cc7c61dfab3f to your computer and use it in GitHub Desktop.
Save barca/6e9044ceb717b53f7839cc7c61dfab3f to your computer and use it in GitHub Desktop.
I assume you use python3.7
import urllib.request
with urllib.request.urlopen('http://python.org/') as response:
html = response.read()
with open("stored.html", "r+") as file:
if not (str(file.read()) == str(html)):
print("THIS IS WHERE YOU ALERT")
file.seek(0) #sets file pointer to beginning
file.truncate() #empties the file
file.write(str(html))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment