notmebotz-tools
Version:
Sebuah Tools yang berfungsi untuk mendownload Video atau Foto dari media sosial, serta sebagai tools yang berguna untuk aplikasi kamu seperti untuk BOT
78 lines (63 loc) • 2.46 kB
JavaScript
const axios = require('axios');
const cheerio = require('cheerio');
async function apkpures(query) {
try {
const searchUrl = `https://apkpure.net/search?q=${encodeURIComponent(query)}`;
const response = await axios.get(searchUrl);
const $ = cheerio.load(response.data);
const apps = [];
$('.apk-item').each((index, element) => {
const $el = $(element);
const href = $el.attr('href');
const title = $el.attr('title');
const packageName = $el.attr('data-dt-pkg');
const icon = $el.find('.app-icon').attr('src');
const developer = $el.find('.dev').text();
const rating = $el.find('.stars').text().trim();
if (href && title) {
apps.push({
title,
developer,
rating,
packageName,
icon,
url: `https://apkpure.net${href}`
});
}
});
const detailedApps = [];
for (const app of apps) {
try {
const detailResponse = await axios.get(app.url);
const $detail = cheerio.load(detailResponse.data);
const appIcon = $detail('.app-icon-img').attr('src');
const appTitle = $detail('h1').first().text().trim();
const appDeveloper = $detail('.developer').text().trim();
const reviews = $detail('li[data-dt-desc="Reviews"] .desc span').first().text();
const fileSize = $detail('li[data-dt-desc="FileSize"] .head').text().trim();
const androidOS = $detail('li[data-dt-desc="AndroidOS"] .head').text().trim();
const rating = $detail('li[data-dt-desc="Reviews"] .head .stars').text().trim();
const downloadUrl = $detail('.download_apk').attr('href');
detailedApps.push({
title: appTitle || app.title,
developer: appDeveloper || app.developer,
rating: rating || app.rating,
reviews,
fileSize,
androidOS,
packageName: app.packageName,
icon: appIcon || app.icon,
url: app.url,
downloadUrl: downloadUrl ? `https://apkpure.net${downloadUrl}` : null
});
await new Promise(resolve => setTimeout(resolve, 1000));
} catch (error) {
detailedApps.push(app);
}
}
return detailedApps;
} catch (error) {
throw new Error(`Error scraping APKPure: ${error.message}`);
}
}
module.exports = { apkpures }