Skip to content

Mediafire download

vellzyy's profile photo@vellzyy Sep 16, 2026 4
javascript · 76 lines
/**
 * Judul : Mediafire Downloader
 * Base Url : https://www.mediafire.com
 * Author : Vellzyy
 * Deskripsi : Scraper untuk mengambil link download dan informasi file dari Mediafire
 * Channel Author : https://whatsapp.com/channel/0029VbD89K11CYoQIft8sQ3b
 * Channel ke dua : https://whatsapp.com/channel/0029VbDl6c1KmCPJErq9ox3F
 */

const axios = require('axios');
const cheerio = require('cheerio');

async function scrapeMediafire(url) {
    try {
        const response = await axios.get(url, {
            timeout: 15000,
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
            }
        });
        
        const $ = cheerio.load(response.data);
        const downloadLink = $('#downloadButton').attr('href');
        
        if (!downloadLink) {
            return {
                status: false,
                message: "Download link not found"
            };
        }

        let filename = $('.dl-btn-label').attr('title');
        if (!filename) {
            filename = $('.promo-download-info .filename').text().trim();
        }
        if (!filename && downloadLink) {
            const urlObj = new URL(downloadLink);
            filename = urlObj.pathname.split('/').pop();
            filename = decodeURIComponent(filename);
        }

        let size = '';
        const sizeText = $('a#downloadButton').text();
        const sizeMatch = sizeText.match(/\((.*?)\)/);
        if (sizeMatch && sizeMatch[1]) {
            size = sizeMatch[1];
        } else {
            size = $('.dl-info .details').text().trim();
        }

        return {
            status: true,
            data: {
                source_url: url,
                download_url: downloadLink,
                filename: filename || "Unknown",
                size: size || "Unknown"
            }
        };
        
    } catch (error) {
        throw new Error(`Gagal mengambil data: ${error.message}`);
    }
}

module.exports = scrapeMediafire;

// Untuk testing langsung
if (require.main === module) {
    const url = process.argv[2];
    if (!url) {
        console.log("Masukkan URL Mediafire");
        process.exit(1);
    }
    scrapeMediafire(url).then(res => console.log(JSON.stringify(res, null, 2))).catch(err => console.error(err));
}
0 0

Comments (0)

No comments yet

Be the first to share feedback or ask a question.

Related snippets

See more javascript