Advertisement
here2share

# weather_stamp_jpg.py

May 19th, 2015
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. # weather_stamp_jpg.py
  2.  
  3. import urllib
  4. import datetime
  5.  
  6. def fetchfile(url,nd2=''):
  7.     now = datetime.datetime.now()
  8.     stamp = now.strftime("%Y-%B-%d-%H%M%p")
  9.     file = unicode("c:\\Weather"+stamp+nd2+".jpg")
  10.     try:
  11.         # fetch the image
  12.         urllib.urlretrieve(url, file)
  13.         print "Image received as", file
  14.     except:
  15.         print "Could not fetch file."
  16.  
  17. fetchfile('http://www.intellicast.com/WxImages/ForecastWeather/conus_day1.jpg')
  18. fetchfile('http://images.intellicast.com/WxImages/CurrentTemps/usa.jpg','_temp')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement