async function searchResults(keyword) { const searchUrl = `https://hds.turkish123.com/?s=${encodeURIComponent(keyword)}`; try { const response = await fetch(searchUrl); const html = await response; const results = []; const itemRegex = /]*class="ml-item"[^>]*>[\s\S]*?<\/div>/g; const items = html.match(itemRegex) || []; items.forEach((itemHtml) => { const titleMatch = itemHtml.match(/

([^<]+)<\/h2><\/span>/); const imgMatch = itemHtml.match(/]*src="([^"]+)"[^>]*class="mli-thumb"/); const hrefMatch = itemHtml.match(/]*class="ml-mask/); if (!titleMatch || !imgMatch || !hrefMatch) return; const title = titleMatch[1].trim(); const imageUrl = imgMatch[1].trim(); const href = hrefMatch[1].trim(); results.push({ title, image: imageUrl, href }); }); //console.log(results); console.log(JSON.stringify(results)); return JSON.stringify(results); } catch (error) { throw error; } } async function extractDetails(url) { const details = []; try { const response = await fetch(url); const html = await response; const descriptionMatch = html.match(/

([\s\S]*?)<\/p>/); let description = descriptionMatch ? descriptionMatch[1].trim() : 'Weirdly the website doesn\'t provide any description, either that or I\'m blind.'; description = description.replace(/–/g, '–').replace(/’/g, '’'); const yearMatch = html.match(/