Spaces:
Paused
Paused
πππππππ πππππππ β‘
commited on
Update search-google.js
Browse files- plugins/search-google.js +65 -1
plugins/search-google.js
CHANGED
|
@@ -214,7 +214,69 @@ Support : wa.me/18062212660
|
|
| 214 |
// GOOGLE CMD
|
| 215 |
|
| 216 |
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
const { cmd } = require("../command");
|
| 219 |
|
| 220 |
cmd({
|
|
@@ -256,3 +318,5 @@ cmd({
|
|
| 256 |
reply(`β οΈ *An error occurred while fetching search results.*\n\n${error.message}`);
|
| 257 |
}
|
| 258 |
});
|
|
|
|
|
|
|
|
|
| 214 |
// GOOGLE CMD
|
| 215 |
|
| 216 |
|
| 217 |
+
|
| 218 |
+
const axios = require('axios');
|
| 219 |
+
const config = require('../config');
|
| 220 |
+
const { cmd, commands } = require('../command');
|
| 221 |
+
|
| 222 |
+
cmd({
|
| 223 |
+
pattern: 'googlesearch',
|
| 224 |
+
alias: ['google', 'gs'],
|
| 225 |
+
react: '',
|
| 226 |
+
desc: 'Perform a Google search.',
|
| 227 |
+
category: 'search',
|
| 228 |
+
filename: __filename
|
| 229 |
+
}, async (conn, mek, m, {
|
| 230 |
+
from,
|
| 231 |
+
quoted,
|
| 232 |
+
body,
|
| 233 |
+
isCmd,
|
| 234 |
+
command,
|
| 235 |
+
args,
|
| 236 |
+
q,
|
| 237 |
+
isGroup,
|
| 238 |
+
sender,
|
| 239 |
+
senderNumber,
|
| 240 |
+
botNumber2,
|
| 241 |
+
botNumber,
|
| 242 |
+
pushname,
|
| 243 |
+
isMe,
|
| 244 |
+
isOwner,
|
| 245 |
+
groupMetadata,
|
| 246 |
+
groupName,
|
| 247 |
+
participants,
|
| 248 |
+
groupAdmins,
|
| 249 |
+
isBotAdmins,
|
| 250 |
+
isAdmins,
|
| 251 |
+
reply
|
| 252 |
+
}) => {
|
| 253 |
+
try {
|
| 254 |
+
if (!q) return reply('Please provide a search query.');
|
| 255 |
+
const apiUrl = `https://www.google.com/search?q=${encodeURIComponent(q)}`;
|
| 256 |
+
const response = await axios.get(apiUrl, {
|
| 257 |
+
headers: {
|
| 258 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36'
|
| 259 |
+
}
|
| 260 |
+
});
|
| 261 |
+
const htmlContent = response.data;
|
| 262 |
+
const $ = cheerio.load(htmlContent);
|
| 263 |
+
const searchResults = [];
|
| 264 |
+
$('div.yuRUbf').each((index, element) => {
|
| 265 |
+
const title = $(element).find('h3').text();
|
| 266 |
+
const link = $(element).find('a').attr('href');
|
| 267 |
+
searchResults.push({ title, link });
|
| 268 |
+
});
|
| 269 |
+
const result = searchResults.map((result, index) => `${index + 1}. ${result.title} - ${result.link}`).join('\n');
|
| 270 |
+
reply(result);
|
| 271 |
+
} catch (error) {
|
| 272 |
+
console.error(error);
|
| 273 |
+
reply(`An error occurred: ${error.message}`);
|
| 274 |
+
}
|
| 275 |
+
});
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
/*const axios = require("axios");
|
| 280 |
const { cmd } = require("../command");
|
| 281 |
|
| 282 |
cmd({
|
|
|
|
| 318 |
reply(`β οΈ *An error occurred while fetching search results.*\n\n${error.message}`);
|
| 319 |
}
|
| 320 |
});
|
| 321 |
+
|
| 322 |
+
*/
|