Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/scripts/data/textpro.js
1126 views
1
const got = require('got')
2
const { load } = require('cheerio')
3
const { writeFileSync } = require('fs')
4
5
const PAGE = 12
6
const MAX_PARAMETERS = 3
7
const BASE_URL = 'https://textpro.me';
8
(async () => {
9
const url = `${BASE_URL}/home-p`
10
const results = []
11
for (let i = 1; i <= PAGE; i++) {
12
const html = await got(`${url}${i}`)
13
const $ = load(html.body)
14
const links = $('div.col-md-12 > div.row > div.col-md-4')
15
links.each(async (i, e) => {
16
const link = $(e).find('a').attr('href')
17
const title = $(e).find('.title-effect-home').text()
18
if (!link || !title) return
19
const html = await got(`${BASE_URL}${link}`)
20
const $$ = load(html.body)
21
const parameters = []
22
for (let j = 0; j <= MAX_PARAMETERS; j++) {
23
const parameter = $$(`#text-${j}`).length
24
const isParameterExist = !!parameter
25
parameters.push(isParameterExist)
26
if (isParameterExist) {
27
// eslint-disable-next-line eqeqeq
28
for (let k = 0; k <= parameter.length; k++) if (parameters[k] == false) throw new Error(`${title} is not parameterized`)
29
}
30
}
31
if (link && title) {
32
results.push({
33
link,
34
title,
35
parameters
36
})
37
}
38
})
39
}
40
writeFileSync('data/textpro.json', JSON.stringify(results, null, 2))
41
})()
42
43