// Url to which you navigate to see all auctions
// https://www.miamidade.realforeclose.com/index.cfm?zaction=USER&zmethod=CALENDAR
// You must be in a specific auction to run the code. Example:
// https://www.miamidade.realforeclose.com/index.cfm?zaction=AUCTION&Zmethod=PREVIEW&AUCTIONDATE=06/14/2021
// Parses the data returned from propery ajax request
function parseData(data){
let html = data.retHTML;
html = html.replace(/@A/g,'
');
html = html.replace(/@E/g,'AUCTION');
html = html.replace(/@F/g,'
');
html = html.replace(/@H/g,' | | ${html}`;
return html;
}
async function getData(totalPages) {
// <= because we are starting at 1
for (let i = 1; i <= totalPages; i++){
const response = await fetch(`https://www.miamidade.realforeclose.com/index.cfm?zaction=AUCTION&Zmethod=UPDATE&FNC=LOAD&AREA=W&PageDir=0&doR=1&tx=1620911413218&bypassPage=${i}&test=1&_=1620911413065`);
const json = await response.json();
const html = parseData(json);
$('body').append(html);
}
const auctionsHtml = $('#cobalt-int-stuff .AUCTION_ITEM');
auctions = [];
auctionsHtml.each((index, auctionToCheck) => {
const auction = {};
const auctionRows = $('table tr', auctionToCheck);
for (let row of auctionRows) {
let label = $('th', row).html();
label = label.trim().replace(' ', '');
if (label === 'ParcelID:') {
auction[label] = $('td a', row).html();;
auction['ParcelLink'] = $('a', row).attr('href');
}
else if (label !== '') {
label = label.trim().replace(' ', '');
auction[label] = $('td', row).html();
}
else {
auction['address2'] = $('td', row).html();
auction.city = auction.address2.split(',')[0];
// We're only going to deal with the first five characters
auction.zipcode = auction.address2.split(',')[1].trim().substring(0, 5);
}
}
auctions.push(auction);
});
}
// Run this command. Make sure to check total number of pages and enter that where I have "3" here
await getData(3);
// After you see "undefined", run this command
copy(auctions); |