refactored main script

This commit is contained in:
1MalcolmS
2026-03-23 23:15:35 -07:00
parent e8fcba378d
commit bc65ed0a2c
2 changed files with 100 additions and 241 deletions

View File

@@ -1,3 +1,5 @@
#testing retreivable images
import requests
from time import time

View File

@@ -10,252 +10,109 @@ headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0
'https://www.portvancouver.com/' }
milliseconds = int(time() * 1000)
image_check = requests.get("https://ehub.portvancouver.com/Webcams/Photos/CommOver?" + str(milliseconds))
x2 = requests.get("https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?" + str(milliseconds))
x3 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?" + str(milliseconds))
x4 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?" + str(milliseconds))
x5 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/VantermGates?" + str(milliseconds))
x6 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?" + str(milliseconds))
x7 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?" + str(milliseconds))
x8 = requests.get("https://ehub.portvancouver.com/webcams/Photos/TerminalDock?" + str(milliseconds))
x9 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?" + str(milliseconds))
x10 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?" + str(milliseconds))
x11 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?" + str(milliseconds))
x12 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?" + str(milliseconds))
x13 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/DMSWest?" + str(milliseconds))
x14 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?" + str(milliseconds))
x15 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?" + str(milliseconds))
x16 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?" + str(milliseconds))
x17 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?" + str(milliseconds))
x18 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?" + str(milliseconds))
x19 = requests.get("https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?" + str(milliseconds))
x1 = requests.Response()
x2 = requests.Response()
x3 = requests.Response()
x4 = requests.Response()
x5 = requests.Response()
x6 = requests.Response()
x7 = requests.Response()
x8 = requests.Response()
x9 = requests.Response()
x10 = requests.Response()
x11 = requests.Response()
x12 = requests.Response()
x13 = requests.Response()
x14 = requests.Response()
x15 = requests.Response()
x16 = requests.Response()
x17 = requests.Response()
x18 = requests.Response()
x19 = requests.Response()
while True:
astr1 = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?"
astr2 = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?"
astr3 = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?"
astr4 = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?"
astr5 = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?"
astr6 = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?"
astr7 = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?"
astr8 = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?"
astr9 = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?"
astr10 = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?"
astr11 = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?"
astr12 = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?"
astr13 = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?"
astr14 = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?"
astr15 = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?"
astr16 = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?"
astr17 = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?"
astr18 = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?"
astr19 = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?"
image_name = "image"
def acquireImage(request_string, folder_name, response):
global image_check
image_check = copy.deepcopy(response)
response = requests.get(request_string, headers=headerz)
if response.content != image_check.content:
with chdir(folder_name):
if response.status_code == 200:
with open(image_name, 'wb') as f:
f.write(response.content)
else:
print("Copy detected and removed (folder_name)")
def getTimeAndName():
milliseconds = int(time() * 1000)
str1 = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?" + str(milliseconds)
str2 = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?" + str(milliseconds)
str3 = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?" + str(milliseconds)
str4 = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?" + str(milliseconds)
str5 = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?" + str(milliseconds)
str6 = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?" + str(milliseconds)
str7 = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?" + str(milliseconds)
str8 = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?" + str(milliseconds)
str9 = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?" + str(milliseconds)
str10 = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?" + str(milliseconds)
str11 = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?" + str(milliseconds)
str12 = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?" + str(milliseconds)
str13 = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?" + str(milliseconds)
str14 = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?" + str(milliseconds)
str15 = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?" + str(milliseconds)
str16 = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?" + str(milliseconds)
str17 = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?" + str(milliseconds)
str18 = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?" + str(milliseconds)
str19 = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?" + str(milliseconds)
global image_name
image_name = "image" + str(milliseconds) + ".jpg"
while True:
getTimeAndName()
acquireImage(astr1 + str(milliseconds), 'Commissioner entrance', x1)
getTimeAndName()
acquireImage(astr2 + str(milliseconds), 'Waterfront_road Centerm crossing', x2)
getTimeAndName()
acquireImage(astr3 + str(milliseconds), 'Centerm in gate', x3)
getTimeAndName()
acquireImage(astr4 + str(milliseconds), 'Vanterm Alliance Grain Terminal crossing', x4)
getTimeAndName()
acquireImage(astr5 + str(milliseconds), 'Vanterm in gate', x5)
getTimeAndName()
acquireImage(astr6 + str(milliseconds), 'Clark Drive overpass', x6)
getTimeAndName()
acquireImage(astr7 + str(milliseconds), 'Columbia Container - crossing', x7)
getTimeAndName()
acquireImage(astr8 + str(milliseconds), 'Terminal dock', x8)
getTimeAndName()
acquireImage(astr9 + str(milliseconds), 'Commissioner truck staging', x9)
getTimeAndName()
acquireImage(astr10 + str(milliseconds), 'Commissioner street overpass', x10)
getTimeAndName()
acquireImage(astr11 + str(milliseconds), 'Deltaport causeway', x11)
getTimeAndName()
acquireImage(astr12 + str(milliseconds), 'Deltaport gate 1', x12)
getTimeAndName()
acquireImage(astr13 + str(milliseconds), 'Delta truck staging', x13)
getTimeAndName()
acquireImage(astr14 + str(milliseconds), 'Fraser Surrey main intersection', x14)
getTimeAndName()
acquireImage(astr15 + str(milliseconds), 'Fraser Surrey in gate', x15)
getTimeAndName()
acquireImage(astr16 + str(milliseconds), 'Fraser Surrey VACS gates', x16)
getTimeAndName()
acquireImage(astr17 + str(milliseconds), 'Fraser Surrey track crossing', x17)
getTimeAndName()
acquireImage(astr18 + str(milliseconds), 'PortsideBlundellNo.8 road intersection', x18)
getTimeAndName()
acquireImage(astr19 + str(milliseconds), 'Portside road - westbound', x19)
x1 = requests.get(str1, headers=headerz)
if x1.content != image_check.content:
with chdir('Commissioner entrance'):
if x1.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x1.content)
else:
print("Copy detected and removed (x1)")
image_check = copy.deepcopy(x2)
x2 = requests.get(str2, headers=headerz)
if x2.content != image_check.content:
with chdir('Waterfront_road Centerm crossing'):
if x2.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x2.content)
else:
print("Copy detected and removed (x2)")
image_check = copy.deepcopy(x3)
x3 = requests.get(str3, headers=headerz)
if x3.content != image_check.content:
with chdir('Centerm in gate'):
if x3.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x3.content)
else:
print("Copy detected and removed (x3)")
image_check = copy.deepcopy(x4)
x4 = requests.get(str4, headers=headerz)
if x4.content != image_check.content:
with chdir('Vanterm Alliance Grain Terminal crossing'):
if x4.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x4.content)
else:
print("Copy detected and removed (x4)")
image_check = copy.deepcopy(x5)
x5 = requests.get(str5, headers=headerz)
if x5.content != image_check.content:
with chdir('Vanterm in gate'):
if x5.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x5.content)
else:
print("Copy detected and removed (x5)")
image_check = copy.deepcopy(x6)
x6 = requests.get(str6, headers=headerz)
if x6.content != image_check.content:
with chdir('Clark Drive overpass'):
if x6.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x6.content)
else:
print("Copy detected and removed (x6)")
image_check = copy.deepcopy(x7)
x7 = requests.get(str7, headers=headerz)
if x7.content != image_check.content:
with chdir('Columbia Container - crossing'):
if x7.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x7.content)
else:
print("Copy detected and removed (x7)")
image_check = copy.deepcopy(x8)
x8 = requests.get(str8, headers=headerz)
if x8.content != image_check.content:
with chdir('Terminal dock'):
if x8.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x8.content)
else:
print("Copy detected and removed (x8)")
image_check = copy.deepcopy(x9)
x9 = requests.get(str9, headers=headerz)
if x9.content != image_check.content:
with chdir('Commissioner truck staging'):
if x9.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x9.content)
else:
print("Copy detected and removed (x9)")
image_check = copy.deepcopy(x10)
x10 = requests.get(str10, headers=headerz)
if x10.content != image_check.content:
with chdir('Commissioner street overpass'):
if x10.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x10.content)
else:
print("Copy detected and removed (x10)")
image_check = copy.deepcopy(x11)
x11 = requests.get(str11, headers=headerz)
if x11.content != image_check.content:
with chdir('Deltaport causeway'):
if x11.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x11.content)
else:
print("Copy detected and removed (x11)")
image_check = copy.deepcopy(x12)
x12 = requests.get(str12, headers=headerz)
if x12.content != image_check.content:
with chdir('Deltaport gate 1'):
if x12.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x12.content)
else:
print("Copy detected and removed (x12)")
image_check = copy.deepcopy(x13)
x13 = requests.get(str13, headers=headerz)
if x13.content != image_check.content:
with chdir('Delta truck staging'):
if x13.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x13.content)
else:
print("Copy detected and removed (x13)")
image_check = copy.deepcopy(x14)
x14 = requests.get(str14, headers=headerz)
if x14.content != image_check.content:
with chdir('Fraser Surrey main intersection'):
if x14.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x14.content)
else:
print("Copy detected and removed (x14)")
image_check = copy.deepcopy(x15)
x15 = requests.get(str15, headers=headerz)
if x15.content != image_check.content:
with chdir('Fraser Surrey in gate'):
if x15.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x15.content)
else:
print("Copy detected and removed (x15)")
image_check = copy.deepcopy(x16)
x16 = requests.get(str16, headers=headerz)
if x16.content != image_check.content:
with chdir('Fraser Surrey VACS gates'):
if x16.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x16.content)
else:
print("Copy detected and removed (x16)")
image_check = copy.deepcopy(x17)
x17 = requests.get(str17, headers=headerz)
if x17.content != image_check.content:
with chdir('Fraser Surrey track crossing'):
if x17.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x17.content)
else:
print("Copy detected and removed (x17)")
image_check = copy.deepcopy(x18)
x18 = requests.get(str18, headers=headerz)
if x18.content != image_check.content:
with chdir('PortsideBlundellNo.8 road intersection'):
if x18.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x18.content)
else:
print("Copy detected and removed (x18)")
image_check = copy.deepcopy(x19)
x19 = requests.get(str19, headers=headerz)
if x19.content != image_check.content:
with chdir('Portside road - westbound'):
if x19.status_code == 200:
with open(image_name, 'wb') as f:
f.write(x19.content)
else:
print("Copy detected and removed (x19)")
image_check = copy.deepcopy(x1)
print("Scanned")