93 lines
3.6 KiB
Plaintext
93 lines
3.6 KiB
Plaintext
import requests
|
|
from time import time
|
|
from time import sleep
|
|
from contextlib import chdir
|
|
import copy
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5', 'Accept-Encoding' :
|
|
'gzip, deflate, br, zstd', 'Accept-Language' :
|
|
'en-CA,en-US;q=0.9,en;q=0.8', 'Referer' :
|
|
'https://www.portvancouver.com/' }
|
|
|
|
milliseconds = int(time() * 1000)
|
|
|
|
x = [requests.Response() for _ in range(20)]
|
|
|
|
print(x)
|
|
|
|
astr = ["Hi!"] * 20
|
|
lastr = ["Hi!"] * 20
|
|
|
|
astr[0] = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?"
|
|
astr[1] = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?"
|
|
astr[2] = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?"
|
|
astr[3] = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?"
|
|
astr[4] = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?"
|
|
astr[5] = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?"
|
|
astr[6] = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?"
|
|
astr[7] = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?"
|
|
astr[8] = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?"
|
|
astr[9] = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?"
|
|
astr[10] = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?"
|
|
astr[11] = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?"
|
|
astr[12] = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?"
|
|
astr[13] = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?"
|
|
astr[14] = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?"
|
|
astr[15] = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?"
|
|
astr[16] = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?"
|
|
astr[17] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?"
|
|
astr[18] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?"
|
|
astr[19] = "https://ehub.portvancouver.com/Webcams/Photos/CPCTruckRoute?"
|
|
|
|
folder = ["Commissioner entrance","Waterfront_road Centerm crossing","Centerm in gate",
|
|
"Vanterm Alliance Grain Terminal crossing", "Vanterm in gate", "Clark Drive overpass",
|
|
"Columbia Container - crossing", "Terminal dock","Commissioner truck staging",
|
|
"Commissioner street overpass", "Deltaport causeway", "Deltaport gate 1",
|
|
"Delta truck staging", "Fraser Surrey main intersection","Fraser Surrey in gate",
|
|
"Fraser Surrey VACS gates", "Fraser Surrey track crossing", "PortsideBlundellNo.8 road intersection",
|
|
"Portside road - westbound", "Convention Centre East"]
|
|
|
|
reference = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
|
|
i = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
|
|
|
|
|
image_name = "image"
|
|
|
|
def acquireImage(request_string, folder_name, response, number):
|
|
image_check = requests.Response()
|
|
image_check = copy.deepcopy(response)
|
|
resp = requests.get(request_string, headers=headerz, timeout=(5,30))
|
|
response._content = resp.content
|
|
response.status_code = resp.status_code
|
|
|
|
if response.content != image_check.content:
|
|
|
|
global i
|
|
i[number] += 1
|
|
image_name = "image" + f"{i[number]:04}" + ".jpg"
|
|
print(response)
|
|
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 getName():
|
|
milliseconds = int(time() * 1000)
|
|
global lastr
|
|
lastr = [s + str(milliseconds) for s in astr]
|
|
|
|
|
|
while True:
|
|
getName()
|
|
|
|
with ThreadPoolExecutor() as executor:
|
|
results = executor.map(acquireImage, lastr, folder, x, reference)
|
|
|
|
print(i)
|
|
|
|
print("Scanned")
|