Skip to content

Instantly share code, notes, and snippets.

@kkestell
Created November 10, 2011 14:39
Show Gist options
  • Save kkestell/1354990 to your computer and use it in GitHub Desktop.
Save kkestell/1354990 to your computer and use it in GitHub Desktop.
McMurdo
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