Agent query: Could you try clicking the refresh button again and let me know if the newsletters appear now?
Fix: Resolve issue where refresh button failed to display newsletters; improve newsletter data handling and date parsing. Screenshot: https://storage.googleapis.com/screenshot-production-us-central1/9dda30b6-4149-4bce-89dc-76333005952c/204cab93-ab2c-4b8d-a2e4-a01a1cf3b19e.jpg
This commit is contained in:
@@ -13,29 +13,38 @@ export async function scrapeNewsletters(): Promise<InsertNewsletter[]> {
|
||||
// The main archive container table
|
||||
$('.archiveTable tr').each((_, element) => {
|
||||
const $element = $(element);
|
||||
|
||||
|
||||
// Extract newsletter details
|
||||
const title = $element.find('.archiveTitle').text().trim();
|
||||
const dateText = $element.find('.archiveDate').text().trim();
|
||||
const url = $element.find('a').attr('href');
|
||||
|
||||
|
||||
if (title && dateText && url) {
|
||||
// Parse the date (format: MM/DD/YYYY)
|
||||
const [month, day, year] = dateText.split('/');
|
||||
const [month, day, year] = dateText.split('/').map(num => num.trim());
|
||||
if (!month || !day || !year) {
|
||||
console.warn('Invalid date format:', dateText);
|
||||
return;
|
||||
}
|
||||
|
||||
const date = `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
||||
|
||||
newsletters.push({
|
||||
title,
|
||||
date,
|
||||
url: `https://app.robly.com${url}`,
|
||||
description: null
|
||||
description: null // Explicitly set to null as we don't have descriptions from the archive page
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (newsletters.length === 0) {
|
||||
throw new Error('No newsletters found in the archive');
|
||||
}
|
||||
|
||||
return newsletters;
|
||||
} catch (error) {
|
||||
console.error('Error scraping newsletters:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user