const axios = require('axios') const cheerio = require('cheerio') async function searchGroups(keywords) { const headers = { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Referer": "https://groupda1.link/add/group/search", "Accept-Language": "en-US,en;q=0.9", "Accept": "text/html, */*; q=0.01", "Host": "groupda1.link", "Origin": "https://groupda1.link", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" } const results = [] const keywordList = keywords.split(',') for (const name of keywordList) { const keyword = name.trim() let loop_count = 0 while (loop_count < 10) { const data = new URLSearchParams({ group_no: `${loop_count}`, search: true, keyword: keyword, category: "Any Category", country: "Indonesia", language: "Bahasa Apa Pun" }) try { const response = await axios.post( "https://groupda1.link/add/group/loadresult", data.toString(), { headers, timeout: 10000 } ) const text = response.data if (!text || text.length === 0) break const $ = cheerio.load(text) let found = false for (const maindiv of $('.maindiv').toArray()) { const tag = $(maindiv).find('a[href]') if (!tag.length) continue const link = tag.attr('href') const title = tag.attr('title').replace('Whatsapp group invite link: ', '') const description_tag = $(maindiv).find('p.descri') const description = description_tag.text().trim() || 'Tidak ada deskripsi' const group_id = link.split('/').pop() const group_link = `https://chat.whatsapp.com/${group_id}` if (!results.some(g => g.Code === group_id)) { results.push({ Name: title, Code: group_id, Link: group_link, Description: description, Keyword: keyword }) found = true } } if (!found) break loop_count++ await new Promise(resolve => setTimeout(resolve, 1000)) } catch (error) { console.error(`Error pada halaman ${loop_count + 1}: ${error.message}`) break } } } return results } return searchGroups("animek")