Created
November 10, 2011 14:39
-
-
Save kkestell/1354990 to your computer and use it in GitHub Desktop.
McMurdo
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
from urllib import urlopen | |
from BeautifulSoup import BeautifulSoup | |
import time | |
import os | |
c = 1; | |
while os.path.exists(os.path.join('images', str(c) + '.jpg')): | |
c = c + 1 | |
while True: | |
oldTime = time.time() | |
html = urlopen("http://www.usap.gov/videoclipsandmaps/mcmwebcam.cfm").read() | |
imgUrl = BeautifulSoup(html).findAll('div', id='camImageBlock', limit=1)[0].findAll('img', limit=1)[0]['src'] | |
imgData = urlopen('http://www.usap.gov/videoclipsandmaps/' + imgUrl).read() | |
fp = open('images/%s.jpg' % str(c), 'wb') | |
fp.write(imgData) | |
fp.close() | |
print 'Saved %s.jpg' % str(c) | |
print 'Waiting %.4fs' % float((oldTime + 9) - time.time()) | |
while(time.time() < oldTime + 9): | |
time.sleep(0.01) | |
c = c + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment