Created
July 30, 2016 04:21
-
-
Save stephanschulz/98e1ea9d4d04d8d8fb4b943dcd8ea416 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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