Path: blob/master/node_modules/@bochilteam/scraper/lib/cjs/images/wallpaper.js
1126 views
"use strict";1var __importDefault = (this && this.__importDefault) || function (mod) {2return (mod && mod.__esModule) ? mod : { "default": mod };3};4Object.defineProperty(exports, "__esModule", { value: true });5exports.wallpaperv3 = exports.wallpaperv2 = exports.wallpaper = void 0;6const cheerio_1 = __importDefault(require("cheerio"));7const got_1 = __importDefault(require("got"));8async function wallpaper(query) {9const data = await (0, got_1.default)(`https://www.shutterstock.com/search/${query}`, {10headers: {11accept: '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',12'accept-encoding': 'gzip, deflate, br',13'accept-language': 'en-US,en;q=0.9,id;q=0.8',14// 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==',15'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'16}17}).text();18const $ = cheerio_1.default.load(data);19const results = [20...new Set([21...$.html().matchAll(/https?:\/\/(image|www)\.shutterstock\.com\/([^"]+)/gim)22]23.map((v) => v[0])24.filter((v) => /.*\.jpe?g|png$/gi.test(v)))25];26return results;27}28exports.wallpaper = wallpaper;29async function wallpaperv2(query, { page, is4K } = { page: 1 }) {30page = page < 2 ? 2 : page;31const 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();32const $ = cheerio_1.default.load(data);33const results = [];34$('div.thumb-container-big').each(function () {35const img = $(this).find('picture > img').attr('src');36if (img)37results.push(img);38});39return results;40}41exports.wallpaperv2 = wallpaperv2;42async function wallpaperv3(query, page = 1) {43const html = await (0, got_1.default)(`https://www.hdwallpapers.in/search/page/${page}?q=${encodeURIComponent(query)}`).text();44const results = [];45const $ = cheerio_1.default.load(html);46$('#content > div.page-content.wallpaper > ul > li.wall').each(function () {47const img = $(this).find('a > img[src]').attr('src');48if (img)49results.push('https://www.hdwallpapers.in' + img);50});51return results;52}53exports.wallpaperv3 = wallpaperv3;54//# sourceMappingURL=wallpaper.js.map5556