const axios = require('axios'); async function googlesearch({ q, page = 1, lang = 'en', safe = 'off' } = {}) { const res = await axios.get('http://goosh.org/q.php', { headers: { referer: 'https://goosh.org/', 'user-agent': 'Mozilla/5.0 (Linux; Android 15) AppleWebKit/537.36 Chrome/130.0.0.0 Mobile Safari/537.36' }, params: { q, start: page, hl: lang, safe, rsz: 'large' } }); const clean = res.data.trim().replace(/^\(,/, '').replace(/\);$/, ''); const data = JSON.parse(clean); return { totalResults: data.searchInformation?.totalResults || '0', searchTime: data.searchInformation?.searchTime || 0, items: (data?.items || []).map((item, i) => ({ no: i + 1, title: item.title, snippet: item.snippet, domain: item.displayLink, url: item.link, icon: item.displayLink ? `https://www.google.com/s2/favicons?domain=${item.displayLink}&sz=64` : null, description: item.pagemap?.metatags?.[0]?.['og:description'] || null, image: item.pagemap?.cse_image?.[0]?.src || null })) }; } /* googlesearch({ q: 'wearedevs.lol' }).then(r => console.log(JSON.stringify(r, null, 2))).catch(e => console.error(e.message)); googlesearch({ q: 'Netanyahu', lang: 'id', safe: 'on' }).then(r => console.log(JSON.stringify(r, null, 2))).catch(e => console.error(e.message)); googlesearch({ q: 'six seven', page: 2 }).then(r => console.log(JSON.stringify(r, null, 2))).catch(e => console.error(e.message)); googlesearch({ q: 'javascript', lang: 'en', safe: 'off' }).then(r => console.log(JSON.stringify(r, null, 2))).catch(e => console.error(e.message)); *\