how to run comparable of specific properties on zillow by bridgedataoutput.com using node.js or python

37 Views Asked by At

how to make a code that run comparable of specific properties on zillow by bridgedataoutput.com apis using python.

i tried alot of time doing alot of codes but nothing works (i have the api).

i tried that doc but cant find comparables on it https://bridgedataoutput.com/docs/platform/API

i have tried zillow webservice but its broken.

thats one of the codes in node.js

import { get } from 'axios';
import { parse } from 'node-html-parser';
import { build } from 'node-xlsx';

const getComparables = async (propertyId) => {
    try {
        const response = await get(`https://www.zillow.com/webservice/GetComparableHomes.htm?zws-id=${ZWSID}&propertyId=${propertyId}`);

        if (response.status === 200) {
            return response.data;
        } else {
            console.error(`Failed to get comparables. Status code: ${response.status}`);
            return null;
        }
    } catch (error) {
        console.error(`Failed to get comparables. Error: ${error.message}`);
        return null;
    }
};

const htmlToJson = (html) => {
    const root = parse(html);
    const rows = root.querySelectorAll('tr');
    const headers = [];
    const data = [];

    rows.forEach((row, i) => {
        const cols = row.querySelectorAll('td');
        if (i === 0) {
            cols.forEach(col => {
                headers.push(col.textContent);
            });
        } else {
            const objCols = {};
            cols.forEach((col, j) => {
                objCols[headers[j]] = col.textContent;
            });
            data.push(objCols);
        }
    });

    return data;
};

const main = async () => {
    const propertyId = '1234567890'; // replace with your property id
    const comparables = await getComparables(propertyId);
    if (comparables) {
        const data = htmlToJson(comparables);
        const xlsxData = [
            {
                name: 'Comps',
                data: data
            }
        ];
        build(xlsxData, { bookType: 'xlsx' });
    }
};

main();
0

There are 0 best solutions below