Skip to content

Instantly share code, notes, and snippets.

@leah
Created October 24, 2019 04:22
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 leah/7dfcc25383f8a095ba700c5c9883a680 to your computer and use it in GitHub Desktop.
Save leah/7dfcc25383f8a095ba700c5c9883a680 to your computer and use it in GitHub Desktop.
def check_changes():
# HTML from website
req = requests.get('https://grossdomesticproduct.com')
web_text = req.text
# Saved HTML
try:
file = open('grossdomesticproduct.html')
file_text = file.read()
file.close()
except FileNotFoundError:
file_text = '' # file doesn't exist yet, no problem
if web_text != file_text:
# Update file with changes
file = open('grossdomesticproduct.html','w+')
file.write(web_text)
file.close()
return True, 'BANKSY! ✨ grossdomesticproduct.com has changed!'
return False, 'No changes to grossdomesticproduct.com. 😪'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment