Created
January 1, 2026 04:55
-
-
Save ONLym22/25da3962f4ee9cca1278799dde73e3db 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 scrapeOneDownloader() { | |
| const baseUrl = 'https://onedownloader.net'; | |
| const targetUrl = `${baseUrl}/id`; | |
| try { | |
| const { data: html } = await axios.get(targetUrl, { | |
| headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' } | |
| }); | |
| const $ = cheerio.load(html); | |
| const hero = { | |
| title: $('h1.title-wbe').text().trim(), | |
| subtitle: $('p.title-sub-wbe').text().trim(), | |
| }; | |
| const howToSteps = $('h2.title-howto').next('.row').find('.card').map((i, el) => { | |
| const stepElement = $(el); | |
| return { | |
| step: i + 1, | |
| title: stepElement.find('h5.card-title').text().trim(), | |
| description: stepElement.find('p.card-text').text().trim(), | |
| imageUrl: `${baseUrl}${stepElement.find('img').attr('src')}`, | |
| }; | |
| }).get(); | |
| const features = $('h3:contains("Mengapa Memilih OneDownloader")').parent().next('.row').find('.col-lg-6 .d-flex').map((_, el) => { | |
| const featureElement = $(el); | |
| return { | |
| title: featureElement.find('h4').text().trim(), | |
| description: featureElement.find('p').text().trim(), | |
| }; | |
| }).get(); | |
| const faqs = $('#accordionExample .accordion-item-border-bottom').map((_, el) => { | |
| const faqElement = $(el); | |
| return { | |
| question: faqElement.find('.accordion-button span.fs-6').text().trim(), | |
| answer: faqElement.find('.accordion-collapse p').text().trim(), | |
| }; | |
| }).get(); | |
| const availableLanguages = $('.dropdown-menu a.dropdown-item').map((_, el) => { | |
| const langElement = $(el); | |
| return { | |
| language: langElement.text().trim(), | |
| url: langElement.attr('href'), | |
| }; | |
| }).get(); | |
| return { | |
| pageTitle: $('head title').text().trim(), | |
| metaDescription: $('meta[name="description"]').attr('content')?.trim() || null, | |
| canonicalUrl: $('link[rel="canonical"]').attr('href') || null, | |
| hero, | |
| howToSteps, | |
| features, | |
| faqs, | |
| availableLanguages | |
| }; | |
| } catch (error) { | |
| throw new Error(`Scraping failed: ${error.message}`); | |
| } | |
| } | |
| scrapeOneDownloader() | |
| .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