Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/images/sticker.js
1126 views
1
import cheerio from 'cheerio';
2
import got from 'got';
3
export async function stickerTelegram(query, page) {
4
const data = await got(`https://combot.org/telegram/stickers?q=${encodeURI(query)}&page=${page || 1}`).text();
5
const $ = cheerio.load(data);
6
const results = [];
7
$('body > div > main > div.page > div > div.stickers-catalogue > div.tab-content > div > div').each(function () {
8
var _a;
9
const title = (_a = $(this).find('.sticker-pack__title').text()) === null || _a === void 0 ? void 0 : _a.trim();
10
const icon = $(this)
11
.find('.sticker-pack__sticker > div.sticker-pack__sticker-inner > div.sticker-pack__sticker-img')
12
.attr('data-src');
13
const link = $(this)
14
.find('.sticker-pack__header > a.sticker-pack__btn')
15
.attr('href');
16
const stickers = [];
17
$(this)
18
.find('.sticker-pack__list > div.sticker-pack__sticker')
19
.each(function () {
20
const sticker = $(this)
21
.find('.sticker-pack__sticker-inner > div.sticker-pack__sticker-img')
22
.attr('data-src');
23
if (sticker)
24
stickers.push(sticker);
25
});
26
results.push({
27
title,
28
icon,
29
link,
30
stickers
31
});
32
});
33
return results;
34
}
35
export async function stickerLine(query) {
36
const data = await got(`https://store.line.me/api/search/sticker?query=${query}&offset=0&limit=36&type=ALL&includeFacets=true`).json();
37
return data.items.map(({ title, productUrl, id, description, payloadForProduct: { staticUrl, animationUrl, soundUrl }, authorId, authorName }) => {
38
return {
39
id,
40
title,
41
description,
42
url: encodeURI('https://store.line.me' + productUrl),
43
sticker: staticUrl,
44
stickerAnimated: animationUrl,
45
stickerSound: soundUrl,
46
authorId,
47
authorName
48
};
49
});
50
}
51
//# sourceMappingURL=sticker.js.map
52