Path: blob/master/node_modules/@bochilteam/scraper/scripts/data/textpro.js
1126 views
const got = require('got')1const { load } = require('cheerio')2const { writeFileSync } = require('fs')34const PAGE = 125const MAX_PARAMETERS = 36const BASE_URL = 'https://textpro.me';7(async () => {8const url = `${BASE_URL}/home-p`9const results = []10for (let i = 1; i <= PAGE; i++) {11const html = await got(`${url}${i}`)12const $ = load(html.body)13const links = $('div.col-md-12 > div.row > div.col-md-4')14links.each(async (i, e) => {15const link = $(e).find('a').attr('href')16const title = $(e).find('.title-effect-home').text()17if (!link || !title) return18const html = await got(`${BASE_URL}${link}`)19const $$ = load(html.body)20const parameters = []21for (let j = 0; j <= MAX_PARAMETERS; j++) {22const parameter = $$(`#text-${j}`).length23const isParameterExist = !!parameter24parameters.push(isParameterExist)25if (isParameterExist) {26// eslint-disable-next-line eqeqeq27for (let k = 0; k <= parameter.length; k++) if (parameters[k] == false) throw new Error(`${title} is not parameterized`)28}29}30if (link && title) {31results.push({32link,33title,34parameters35})36}37})38}39writeFileSync('data/textpro.json', JSON.stringify(results, null, 2))40})()414243