Defer property assessor email gate
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
import {
|
||||
createPageSession,
|
||||
dismissCommonOverlays,
|
||||
@@ -61,8 +63,8 @@ async function collectListingUrl(page) {
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const address = String(process.argv[2] || "").trim();
|
||||
export async function discoverZillowListing(rawAddress) {
|
||||
const address = String(rawAddress || "").trim();
|
||||
const identity = parseAddressIdentity(address);
|
||||
const searchUrl = `https://www.zillow.com/homes/${encodeURIComponent(buildZillowAddressSlug(address))}_rb/`;
|
||||
const { context, page } = await createPageSession({ headless: process.env.HEADLESS !== "false" });
|
||||
@@ -105,30 +107,36 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
process.stdout.write(
|
||||
`${JSON.stringify(
|
||||
{
|
||||
source: "zillow",
|
||||
address,
|
||||
searchUrl,
|
||||
finalUrl: page.url(),
|
||||
title: await page.title(),
|
||||
listingUrl,
|
||||
attempts,
|
||||
},
|
||||
null,
|
||||
2
|
||||
)}\n`
|
||||
);
|
||||
const result = {
|
||||
source: "zillow",
|
||||
address,
|
||||
searchUrl,
|
||||
finalUrl: page.url(),
|
||||
title: await page.title(),
|
||||
listingUrl,
|
||||
attempts,
|
||||
};
|
||||
await context.close();
|
||||
return result;
|
||||
} catch (error) {
|
||||
try {
|
||||
await context.close();
|
||||
} catch {
|
||||
// Ignore close errors after the primary failure.
|
||||
}
|
||||
throw new Error(`Zillow discovery failed: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const result = await discoverZillowListing(process.argv[2]);
|
||||
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
||||
} catch (error) {
|
||||
fail("Zillow discovery failed.", error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
main();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user