fix: refine scraper output behavior
This commit is contained in:
@@ -87,6 +87,12 @@ function parseEbayPrice(
|
||||
cleaned.toUpperCase().includes("US $")
|
||||
) {
|
||||
currency = "USD";
|
||||
} else if (cleaned.includes("£")) {
|
||||
currency = "GBP";
|
||||
} else if (cleaned.includes("€")) {
|
||||
currency = "EUR";
|
||||
} else if (cleaned.includes("¥")) {
|
||||
currency = "JPY";
|
||||
}
|
||||
|
||||
return { cents, currency };
|
||||
|
||||
@@ -1180,13 +1180,13 @@ export default async function fetchFacebookItems(
|
||||
|
||||
console.log(`\nFound ${ads.length} raw ads. Processing...`);
|
||||
|
||||
const progressBar = new cliProgress.SingleBar(
|
||||
{},
|
||||
cliProgress.Presets.shades_classic,
|
||||
);
|
||||
const isTTY = process.stdout?.isTTY ?? false;
|
||||
const progressBar = isTTY
|
||||
? new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic)
|
||||
: null;
|
||||
const totalProgress = ads.length;
|
||||
const currentProgress = 0;
|
||||
progressBar.start(totalProgress, currentProgress);
|
||||
progressBar?.start(totalProgress, currentProgress);
|
||||
|
||||
const items = parseFacebookAds(ads);
|
||||
|
||||
@@ -1196,8 +1196,8 @@ export default async function fetchFacebookItems(
|
||||
typeof item.listingPrice?.cents === "number" && item.listingPrice.cents >= 0,
|
||||
);
|
||||
|
||||
progressBar.update(totalProgress);
|
||||
progressBar.stop();
|
||||
progressBar?.update(totalProgress);
|
||||
progressBar?.stop();
|
||||
|
||||
console.log(`\nParsed ${pricedItems.length} Facebook marketplace listings.`);
|
||||
return finalizeResults(pricedItems);
|
||||
|
||||
Reference in New Issue
Block a user