This commit is contained in:
2025-06-12 10:02:59 +09:00
parent 9349c6e95b
commit 0760909de1

View File

@ -11,6 +11,11 @@ export interface ExtractedContent {
// Singleton browser instance for reuse // Singleton browser instance for reuse
let sharedBrowser: Browser | null = null; let sharedBrowser: Browser | null = null;
// Helper function to replace page.waitForTimeout
async function waitForTimeout(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Dynamic content handling function // Dynamic content handling function
async function handleDynamicContent(page: any): Promise<void> { async function handleDynamicContent(page: any): Promise<void> {
try { try {
@ -90,7 +95,7 @@ async function handleDynamicContent(page: any): Promise<void> {
const button = await page.$(selector); const button = await page.$(selector);
if (button) { if (button) {
await button.click(); await button.click();
await page.waitForTimeout(2000); await waitForTimeout(2000);
break; break;
} }
} catch (e) { } catch (e) {
@ -117,12 +122,12 @@ async function handleDynamicContent(page: any): Promise<void> {
]); ]);
// Final wait for any remaining dynamic content // Final wait for any remaining dynamic content
await page.waitForTimeout(2000); await waitForTimeout(2000);
} catch (error) { } catch (error) {
console.log('Dynamic content handling failed, using basic timeout:', error); console.log('Dynamic content handling failed, using basic timeout:', error);
// If dynamic content handling fails, continue with basic timeout // If dynamic content handling fails, continue with basic timeout
await page.waitForTimeout(3000); await waitForTimeout(3000);
} }
console.log('Dynamic content handling completed.'); console.log('Dynamic content handling completed.');
} }