2024-03-10 18:49:39 +00:00
|
|
|
import json
|
|
|
|
|
from urllib.request import urlretrieve
|
|
|
|
|
from tqdm import tqdm
|
2024-03-11 14:43:53 +00:00
|
|
|
from data_access import Listing
|
2024-03-10 18:49:39 +00:00
|
|
|
|
2024-03-11 14:43:53 +00:00
|
|
|
for listing in tqdm(Listing.get_all_listings()):
|
|
|
|
|
with open(listing.path_detail_json()) as f:
|
2024-03-10 18:49:39 +00:00
|
|
|
detail = json.load(f)
|
2024-03-25 20:48:48 +00:00
|
|
|
|
2024-04-01 15:26:34 +02:00
|
|
|
# for photo in detail["property"]["photos"]:
|
|
|
|
|
# url = photo["maxSizeUrl"]
|
|
|
|
|
# picname = url.split("/")[-1]
|
|
|
|
|
# order = photo["order"]
|
|
|
|
|
# p = listing.path_pic_file(order, picname)
|
|
|
|
|
# if p.exists():
|
|
|
|
|
# continue
|
|
|
|
|
# tqdm.write(str(p))
|
|
|
|
|
# urlretrieve(url, p)
|
2024-03-25 20:48:48 +00:00
|
|
|
|
|
|
|
|
for photo in detail["property"]["floorplans"]:
|
|
|
|
|
url = photo["url"]
|
|
|
|
|
picname = url.split("/")[-1]
|
|
|
|
|
order = photo["order"]
|
2024-03-11 14:43:53 +00:00
|
|
|
p = listing.path_floorplan_file(order, picname)
|
|
|
|
|
if p.exists():
|
2024-03-10 18:49:39 +00:00
|
|
|
continue
|
2024-03-11 14:43:53 +00:00
|
|
|
tqdm.write(str(p))
|
|
|
|
|
urlretrieve(url, p)
|