const fetch = require('node-fetch'); async function webSearch(query) { const url = `https://duckduckgo.com/html/?q=${encodeURIComponent(query)}`; const response = await fetch(url); const html = await response.text(); // Very naive parsing: extract titles from tags const titles = []; const regex = /]*>([^<]+)<\/a>/g; let match; while ((match = regex.exec(html)) !== null) { titles.push(match[1]); } return titles.slice(0, 5); } module.exports = { webSearch };