Skip to content

Instantly share code, notes, and snippets.

@awave1
Created February 15, 2019 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awave1/0c428b0040bd0897b3bd6c551235436e to your computer and use it in GitHub Desktop.
Save awave1/0c428b0040bd0897b3bd6c551235436e to your computer and use it in GitHub Desktop.
import urllib.request
import datetime
import os
if not os.path.exists('images/'):
os.makedirs('images/')
def dl_jpg(url, file_path, file_name):
full_path = file_path + file_name + '.jpg'
urllib.request.urlretrieve(url,full_path)
currentDT = datetime.datetime.now()
for x in range(116):
if x not in [9, 106, 107, 109, 110, 112]:
url = 'http://trafficcam.calgary.ca/loc' + str(x) + '.jpg'
file_name = "log" + str(x) + 'm' + str(currentDT.month) + 'd'+ str(currentDT.day) + 'h'+ str(currentDT.hour) + 'm'+ str(currentDT.minute)
print(url)
print(file_name)
dl_jpg(url, 'images/', file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment