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