(link)
| 65 | } |
| 66 | // 17. Fetch page content |
| 67 | const fetchPageContent = async (link) => { |
| 68 | console.log(`7. Fetching page content for ${link}`); |
| 69 | try { |
| 70 | const response = await fetch(link); |
| 71 | if (!response.ok) { |
| 72 | return ""; // skip if fetch fails |
| 73 | } |
| 74 | const text = await response.text(); |
| 75 | return extractMainContent(text, link); |
| 76 | } catch (error) { |
| 77 | console.error(`Error fetching page content for ${link}:`, error); |
| 78 | return ''; |
| 79 | } |
| 80 | }; |
| 81 | // 18. Extract main content from the HTML page |
| 82 | function extractMainContent(html, link) { |
| 83 | console.log(`8. Extracting main content from HTML for ${link}`); |
no test coverage detected