wrongmove/crawler/main_tmp.py

41 lines
1 KiB
Python
Raw Normal View History

def record():
from rec.query import listing_query, detail_query
import json
2024-03-25 20:48:48 +00:00
page = 1
listing = listing_query(page, 2, 2, 5, 200000, 500000)
2024-03-25 20:48:48 +00:00
with open(
f"/Users/kadir/code/realestate/crawler/code/json/queries/listing{page}.json",
"w",
) as f:
json.dump(listing, f)
2024-03-25 20:48:48 +00:00
for prop in listing["properties"]:
identifier = prop["identifier"]
resp = detail_query(identifier)
# print(identifier, resp.status_code)
2024-03-25 20:48:48 +00:00
with open(
f"/Users/kadir/code/realestate/crawler/code/json/queries/detail_{identifier}.json",
"w",
) as f:
json.dump(resp, f)
2024-03-25 20:48:48 +00:00
def process():
import json
import pathlib
2024-03-25 20:48:48 +00:00
path = pathlib.Path("/Users/kadir/code/realestate/crawler/code/json/queries/")
detailjsons = list(path.glob("detail_*json"))
for file in detailjsons:
with open(file) as f:
js = json.load(f)
2024-03-25 20:48:48 +00:00
for floorplan in js["property"]["floorplans"]:
print(floorplan["url"])
# record()
2024-03-25 20:48:48 +00:00
process()