(html, link)
| 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}`); |
| 84 | const $ = html.length ? cheerio.load(html) : null |
| 85 | $("script, style, head, nav, footer, iframe, img").remove(); |
| 86 | return $("body").text().replace(/\s+/g, " ").trim(); |
| 87 | } |
| 88 | // 19. Process and vectorize the content |
| 89 | let vectorCount = 0; |
| 90 | const fetchAndProcess = async (item) => { |