Atualização automática: 2026-05-23 22:02:28

This commit is contained in:
Hermes
2026-05-23 22:02:28 +00:00
parent 7cfc1724d3
commit bfa0ab4394
6 changed files with 152 additions and 14 deletions
+6 -3
View File
@@ -71,7 +71,7 @@ class SmartCloner {
}
}
async cloneSite(url, maxPages = 20) {
async cloneSite(url, maxPages = 20, customFolderName = null) {
console.log(`\n🚀 INICIANDO DEEP SMART CLONE: ${url}`);
console.log(`📂 Limite de páginas: ${maxPages}\n`);
@@ -82,7 +82,8 @@ class SmartCloner {
const urlObj = new URL(url);
const siteName = this.sanitizeFilename(urlObj.hostname);
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const siteDir = path.join(this.baseOutputDir, `${siteName}_${timestamp}`);
const finalFolderName = customFolderName ? this.sanitizeFilename(customFolderName) : `${siteName}_${timestamp}`;
const siteDir = path.join(this.baseOutputDir, finalFolderName);
this.ensureDirectoryExists(siteDir);
browser = await chromium.launch({
@@ -368,10 +369,12 @@ if (require.main === module) {
const args = process.argv.slice(2);
const urlArg = args.find(arg => arg.startsWith('--url='));
const url = urlArg ? urlArg.split('=')[1] : args[0];
const folderArg = args.find(arg => arg.startsWith('--folderName='));
const folderName = folderArg ? folderArg.split('=')[1] : null;
if (url) {
const cloner = new SmartCloner();
cloner.cloneSite(url).then(res => {
cloner.cloneSite(url, 20, folderName).then(res => {
console.log(JSON.stringify(res, null, 2));
process.exit(res.success ? 0 : 1);
});
+5 -4
View File
@@ -65,7 +65,7 @@ class WgetCloner {
}
}
async cloneWebsite(url) {
async cloneWebsite(url, customFolderName = null) {
console.log(`\n${'='.repeat(60)}`);
console.log(`🚀 CLONAGEM PROFISSIONAL COM WGET`);
console.log(`${'='.repeat(60)}`);
@@ -98,7 +98,8 @@ class WgetCloner {
const urlObj = new URL(url);
const siteName = this.sanitizeFilename(urlObj.hostname);
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const siteDir = path.join(this.baseOutputDir, `${siteName}_${timestamp}`);
const finalFolderName = customFolderName ? this.sanitizeFilename(customFolderName) : `${siteName}_${timestamp}`;
const siteDir = path.join(this.baseOutputDir, finalFolderName);
this.ensureDirectoryExists(siteDir);
console.log(`📁 Salvando em: ${siteDir}\n`);
@@ -328,13 +329,13 @@ class WgetCloner {
// API
app.post('/wget-clone', async (req, res) => {
try {
const { url } = req.body;
const { url, folderName } = req.body;
if (!url) {
return res.status(400).json({ error: 'URL obrigatória' });
}
const cloner = new WgetCloner();
const result = await cloner.cloneWebsite(url);
const result = await cloner.cloneWebsite(url, folderName);
res.json({ success: true, data: result });
} catch (error) {