lurcloud 1.0.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  const { gdrive, dropbox, mediafire, fetchDownloadLinks, getDownloadLink } = require('./lib/downloader')
2
2
  const { rainbow, blur, invert, blue, greyscale, circle, heart, comrade } = require('./lib/maker')
3
+ const { google } = require('./lib/searcher')
3
4
 
4
5
  module.exports = {
5
6
  gdrive, dropbox, mediafire,
6
7
  fetchDownloadLinks, getDownloadLink,
7
8
 
8
9
  rainbow, blur, invert, blue,
9
- greyscale, circle, heart, comrade
10
+ greyscale, circle, heart, comrade,
11
+
12
+ google
10
13
  }
@@ -0,0 +1,25 @@
1
+ const axios = require('axios')
2
+ const cheerio = require('cheerio')
3
+
4
+ async function google(query) {
5
+ try {
6
+ const { data } = await axios.get(`https://www.google.com/search?q=${encodeURIComponent(query)}`, {
7
+ headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' }
8
+ })
9
+ const $ = cheerio.load(data)
10
+ let results = []
11
+ $('.g').each((i, el) => {
12
+ const title = $(el).find('h3').text()
13
+ const link = $(el).find('a').attr('href')
14
+ const desc = $(el).find('.VwiC3b').text()
15
+ if (title && link) {
16
+ results.push({ title, link, desc })
17
+ }
18
+ })
19
+ return results.slice(0, 5)
20
+ } catch (e) {
21
+ return []
22
+ }
23
+ }
24
+
25
+ module.exports = { google }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lurcloud",
3
- "version": "1.0.0",
3
+ "version": "1.1.2",
4
4
  "description": "Un scraper ligero y modular para Node.js, basado en axios, cheerio y got",
5
5
  "main": "index.js",
6
6
  "keywords": [