const axios = require('axios');
const cheerio = require('cheerio');
class ATL {
constructor(proxy = 'https://uncors.netlify.app/?destination=') {
this.proxy = proxy;
}
parse_img(url) {
if (!url) return null;
try {
const params = new URLSearchParams(new URL(url).search);
return params.get('url') || url;
} catch {
return url;
}
}
homepage = async function (max_pages = 1) {
try {
if (isNaN(max_pages)) throw new Error('Max pages must be a number.');
const { data } = await axios.get(`${this.proxy}https://asiantolick.com/`);
const $ = cheerio.load(data);
const result = [];
$('div#container a.miniatura').each((_, el) => {
const href = $(el).attr('href');
const title = $(el).find('span.titulo_video').text().replace(/\p{Emoji}/gu, '').trim();
const total_images = $(el).find('div.contar_imagens').text().replace(/\D/g, '').trim();
const imgEl = $(el).find('img.miniaturaImg');
const cover = imgEl.attr('data-src') || imgEl.attr('src-original') || imgEl.attr('src');
const post_id = imgEl.attr('post-id') || null;
const is_hd = $(el).find('span.tt_tag_hd').length > 0;
const is_non_nude = $(el).find('span.tt_tag_non_nude').length > 0;
if (href && title && cover) {
result.push({
post_id,
title,
total_images,
cover: this.parse_img(cover),
is_hd,
is_non_nude,
url: href
});
}
});
for (let index = 1; index < max_pages; index++) {
const { data: ajaxData } = await axios.get(`${this.proxy}https://asiantolick.com/ajax/buscar_posts.php`, {
params: {
index,
ver: 11
}
});
if (!ajaxData || ajaxData === 'fim') break;
const $ajax = cheerio.load(ajaxData);
let found = 0;
$ajax('a.miniatura').each((_, el) => {
const href = $ajax(el).attr('href');
const title = $ajax(el).find('span.titulo_video').text().replace(/\p{Emoji}/gu, '').trim();
const total_images = $ajax(el).find('div.contar_imagens').text().replace(/\D/g, '').trim();
const imgEl = $ajax(el).find('img.miniaturaImg');
const cover = imgEl.attr('data-src') || imgEl.attr('src-original') || imgEl.attr('src');
const post_id = imgEl.attr('post-id') || null;
const is_hd = $ajax(el).find('span.tt_tag_hd').length > 0;
const is_non_nude = $ajax(el).find('span.tt_tag_non_nude').length > 0;
if (href && title && cover) {
result.push({
post_id,
title,
total_images,
cover: this.parse_img(cover),
is_hd,
is_non_nude,
url: href
});
found++;
}
});
if (!found) break;
}
return result;
} catch (error) {
throw new Error(error.message);
}
}
search = async function (query, max_pages = 1) {
try {
if (!query) throw new Error('Query is required.');
if (isNaN(max_pages)) throw new Error('Max pages must be a number.');
const { data } = await axios.get(`${this.proxy}https://asiantolick.com/search/${encodeURIComponent(query)}`);
const $ = cheerio.load(data);
const result = [];
$('div#container a.miniatura').each((_, el) => {
const href = $(el).attr('href');
const title = $(el).find('span.titulo_video').text().replace(/\p{Emoji}/gu, '').trim();
const total_images = $(el).find('div.contar_imagens').text().replace(/\D/g, '').trim();
const imgEl = $(el).find('img.miniaturaImg');
const cover = imgEl.attr('data-src') || imgEl.attr('src-original') || imgEl.attr('src');
const post_id = imgEl.attr('post-id') || null;
const is_hd = $(el).find('span.tt_tag_hd').length > 0;
const is_non_nude = $(el).find('span.tt_tag_non_nude').length > 0;
if (href && title && cover) {
result.push({
post_id,
title,
total_images,
cover: this.parse_img(cover),
is_hd,
is_non_nude,
url: href
});
}
});
for (let index = 1; index < max_pages; index++) {
const { data: ajaxData } = await axios.get(`${this.proxy}https://asiantolick.com/ajax/buscar_posts.php`, {
params: {
search: query,
index,
ver: 42
}
});
if (!ajaxData || ajaxData === 'fim') break;
const $ajax = cheerio.load(ajaxData);
let found = 0;
$ajax('a.miniatura').each((_, el) => {
const href = $ajax(el).attr('href');
const title = $ajax(el).find('span.titulo_video').text().replace(/\p{Emoji}/gu, '').trim();
const total_images = $ajax(el).find('div.contar_imagens').text().replace(/\D/g, '').trim();
const imgEl = $ajax(el).find('img.miniaturaImg');
const cover = imgEl.attr('data-src') || imgEl.attr('src-original') || imgEl.attr('src');
const post_id = imgEl.attr('post-id') || null;
const is_hd = $ajax(el).find('span.tt_tag_hd').length > 0;
const is_non_nude = $ajax(el).find('span.tt_tag_non_nude').length > 0;
if (href && title && cover) {
result.push({
post_id,
title,
total_images,
cover: this.parse_img(cover),
is_hd,
is_non_nude,
url: href
});
found++;
}
});
if (!found) break;
}
return result;
} catch (error) {
throw new Error(error.message);
}
}
detail = async function (url) {
try {
if (!url.includes('asiantolick.com')) throw new Error('Invalid url.');
const { data } = await axios.get(`${this.proxy}${url}`);
const $ = cheerio.load(data);
const article = $('main#post_content article');
const meta = article.find('#metadata_qrcode > div:first-child span');
const title = article.find('h1').text().trim() || null;
const likeScript = data.match(/var likes = (\d+);\s*var unlikes = (\d+);/);
let thumbs_up = null;
if (likeScript) {
const likes = parseInt(likeScript[1]);
const unlikes = parseInt(likeScript[2]);
const total = likes + unlikes;
if (total > 0) {
thumbs_up = likes > unlikes ? ((likes / total) * 100).toFixed(1) + '%' : unlikes > likes ? '-' + ((unlikes / total) * 100).toFixed(1) + '%' : '50%';
}
}
const getMetaVal = (i) => {
const txt = meta.eq(i).text();
const idx = txt.indexOf(':');
return idx !== -1 ? txt.slice(idx + 1).trim() : null;
};
const upload_date = getMetaVal(1);
const total_pics = getMetaVal(2);
const pic_size = getMetaVal(3);
const album_size = getMetaVal(4);
const category = article.find('#categoria_tags_post a[href*="category"]').first().text().trim() || null;
const tags = [];
article.find('#categoria_tags_post a[href*="/tag-"]').each((_, el) => {
const tag = $(el).text().trim().replace(/^#/, '');
if (tag) tags.push(tag);
});
const pics = [];
article.find('.spotlight-group > div[data-src]').each((_, el) => {
const imgSrc = $(el).find('img.miniaturaImg').attr('src');
const dataSrc = $(el).attr('data-src');
const src = dataSrc || imgSrc;
const parsed = this.parse_img(src);
if (parsed) pics.push(parsed);
});
const download_url = article.find('a#download_post').attr('href') || null;
return {
title,
thumbs_up,
upload_date,
total_pics,
pic_size,
album_size,
category,
tags,
pics,
download_url
};
} catch (error) {
throw new Error(error.message);
}
}
}
const a = new ATL();
a.search('loli', 2).then(console.log);