Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/lib/cjs/images/wallpaper.js
1126 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
exports.wallpaperv3 = exports.wallpaperv2 = exports.wallpaper = void 0;
7
const cheerio_1 = __importDefault(require("cheerio"));
8
const got_1 = __importDefault(require("got"));
9
async function wallpaper(query) {
10
const data = await (0, got_1.default)(`https://www.shutterstock.com/search/${query}`, {
11
headers: {
12
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
13
'accept-encoding': 'gzip, deflate, br',
14
'accept-language': 'en-US,en;q=0.9,id;q=0.8',
15
// cookie: '_csrf=DLixL776iH1Yv7Ck9wHekk24; _ga=GA1.2.1481444664.1639216586; _gid=GA1.2.348540858.1639216586; _gat=1; _hjFirstSeen=1; _hjSession_2571802=eyJpZCI6ImVkZDUzMWJhLWNjYTgtNDgyMy1hZmUyLWVjNmFhNWMxZjg3ZCIsImNyZWF0ZWQiOjE2MzkyMTY1ODY0Nzl9; _hjAbsoluteSessionInProgress=0; _hjSessionUser_2571802=eyJpZCI6IjIxZGNhYTc5LWRlMTgtNWE5Ni05ZWE2LTdkYjg4NGZhNjIxMSIsImNyZWF0ZWQiOjE2MzkyMTY1ODYyNDMsImV4aXN0aW5nIjp0cnVlfQ==',
16
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
17
}
18
}).text();
19
const $ = cheerio_1.default.load(data);
20
const results = [
21
...new Set([
22
...$.html().matchAll(/https?:\/\/(image|www)\.shutterstock\.com\/([^"]+)/gim)
23
]
24
.map((v) => v[0])
25
.filter((v) => /.*\.jpe?g|png$/gi.test(v)))
26
];
27
return results;
28
}
29
exports.wallpaper = wallpaper;
30
async function wallpaperv2(query, { page, is4K } = { page: 1 }) {
31
page = page < 2 ? 2 : page;
32
const data = await (0, got_1.default)(`https://wall.alphacoders.com/by_category.php?id=3&name=${encodeURIComponent(query).replace(/%20/g, '+')}&quickload=50&page=${page}${is4K ? '&filter=4K+Ultra+HD' : ''}`).text();
33
const $ = cheerio_1.default.load(data);
34
const results = [];
35
$('div.thumb-container-big').each(function () {
36
const img = $(this).find('picture > img').attr('src');
37
if (img)
38
results.push(img);
39
});
40
return results;
41
}
42
exports.wallpaperv2 = wallpaperv2;
43
async function wallpaperv3(query, page = 1) {
44
const html = await (0, got_1.default)(`https://www.hdwallpapers.in/search/page/${page}?q=${encodeURIComponent(query)}`).text();
45
const results = [];
46
const $ = cheerio_1.default.load(html);
47
$('#content > div.page-content.wallpaper > ul > li.wall').each(function () {
48
const img = $(this).find('a > img[src]').attr('src');
49
if (img)
50
results.push('https://www.hdwallpapers.in' + img);
51
});
52
return results;
53
}
54
exports.wallpaperv3 = wallpaperv3;
55
//# sourceMappingURL=wallpaper.js.map
56