Created
January 1, 2026 04:51
-
-
Save ONLym22/41bb5b7510edbc104755a3b51b5b9744 to your computer and use it in GitHub Desktop.
Uploaded via ONLym Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios'); | |
| const cheerio = require('cheerio'); | |
| /** | |
| * @returns {Promise<Object>} Scraped data object | |
| */ | |
| async function scrapeTinyWowRemoveBg() { | |
| const url = 'https://tinywow.com/image/remove-bg'; | |
| try { | |
| const { data: html } = await axios.get(url, { | |
| headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' } | |
| }); | |
| const $ = cheerio.load(html); | |
| const howToSteps = []; | |
| $('section.py-12 div.grid > div').each((i, el) => { | |
| const step = $(el).find('span').text().trim(); | |
| const description = $(el).find('p').text().trim(); | |
| if (step && description) { | |
| howToSteps.push({ step, description }); | |
| } | |
| }); | |
| const footerLinks = {}; | |
| $('footer h4').each((i, el) => { | |
| const category = $(el).text().trim(); | |
| const links = []; | |
| $(el).next('ul').find('a').each((j, linkEl) => { | |
| links.push({ | |
| text: $(linkEl).text().trim(), | |
| link: $(linkEl).attr('href') | |
| }); | |
| }); | |
| if (links.length) { | |
| footerLinks[category] = links; | |
| } | |
| }); | |
| const footerToolLinks = []; | |
| $('footer h4:contains("Tools")').next('.row').find('a').each((i, el) => { | |
| footerToolLinks.push({ | |
| text: $(el).text().trim(), | |
| link: $(el).attr('href') | |
| }); | |
| }); | |
| if (footerToolLinks.length > 0) { | |
| footerLinks['Tools'] = footerToolLinks; | |
| } | |
| return { | |
| pageTitle: $('title').text().trim(), | |
| mainHeading: $('div.compress_area h1.title_lg').text().trim(), | |
| description: $('div.compress_area h1.title_lg + p').text().trim(), | |
| howToSection: { | |
| title: $('section.py-12 h2.section-title').text().trim(), | |
| steps: howToSteps, | |
| }, | |
| beforeAndAfterSection: { | |
| title: $('.before-after h2.title').text().trim(), | |
| description: $('.before-after p.before-after_note').text().trim(), | |
| images: { | |
| before: $('.before-after_comparison-resize img').attr('src'), | |
| after: $('.ba-slider > picture > img').attr('src') | |
| } | |
| }, | |
| footerLinks | |
| }; | |
| } catch (error) { | |
| throw new Error(`Scraping failed: ${error.message}`); | |
| } | |
| } | |
| scrapeTinyWowRemoveBg() | |
| .then(data => console.log(JSON.stringify(data, null, 2))) | |
| .catch(error => console.error(error.message)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment