Skip to content

Instantly share code, notes, and snippets.

@stephanschulz
Created July 30, 2016 04:21
Show Gist options
  • Save stephanschulz/98e1ea9d4d04d8d8fb4b943dcd8ea416 to your computer and use it in GitHub Desktop.
Save stephanschulz/98e1ea9d4d04d8d8fb4b943dcd8ea416 to your computer and use it in GitHub Desktop.
# save-webpage.py
# http://programminghistorian.org/lessons/code-reuse-and-modularity
# modifications needed to run on raspberry pi with python 3
# http://stackoverflow.com/questions/2792650/python3-error-import-error-no-module-name-urllib
import urllib
from urllib.request import urlopen
import time
import datetime
url = 'https://ca.finance.yahoo.com/q/op?s=AAPL'
systemTime = time.time()
# print ("systemTime "+systemTime)
timeStamp = datetime.datetime.fromtimestamp(systemTime).strftime('%Y-%m-%d-%H-%M-%S')
print ("timeStamp = "+timeStamp)
response = urlopen(url)
webContent = response.read()
f = open('/home/pi/'+timeStamp +'.html', 'wb')
f.write(webContent)
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment