Spaces:
Runtime error
Runtime error
Download data.html from shensuming/gemini: direct link, hf CLI and curl.
- Browser
- Download file 14.2 kB
-
https://huggingface.co/spaces/shensuming/gemini/resolve/main/data.html
- Command line
-
hf download hf://spaces/shensuming/gemini/data.html
-
curl -L -o data.html https://huggingface.co/spaces/shensuming/gemini/resolve/main/data.html
14.2 kB
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>CerebrateX - 数据整理</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| </head> | |
| <body class="bg-slate-50 min-h-screen"> | |
| <div class="max-w-4xl mx-auto py-12 px-6"> | |
| <h1 class="text-3xl font-bold text-slate-900 mb-2 tracking-tight">📋 数据整理</h1> | |
| <p class="text-sm text-slate-500 mb-8">粘贴生数据 → 格式清洗 + 去重 → DNS验证 → 复制干净列表 → 拿去 CRM/SES 发送</p> | |
| <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6 mb-8"> | |
| <h2 class="text-xl font-bold text-slate-800">🚫 退信记录管理</h2> | |
| <p class="text-sm text-slate-500">上传 SES 退信 CSV 或退信 txt,自动存入数据库,下次整理时自动过滤。</p> | |
| <div class="flex flex-wrap gap-3 items-center"> | |
| <input type="file" id="bounceFileInput" accept=".txt,.csv,.tsv" multiple class="text-sm text-slate-600 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-slate-100 file:text-slate-700 hover:file:bg-slate-200"> | |
| <span id="bounceStatus" class="text-xs text-slate-400">数据库已记录 <span id="bounceCount">0</span> 个退信地址</span> | |
| <button onclick="clearBounceData()" class="text-xs text-red-500 hover:text-red-700 ml-auto"></button> | |
| </div> | |
| </div> | |
| <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6 mb-8"> | |
| <h2 class="text-xl font-bold text-slate-800">🔑 Admin Token</h2> | |
| <input type="password" id="adminToken" placeholder="输入 Admin Token(DNS验证/导入退信时使用)" class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm"> | |
| </div> | |
| <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6"> | |
| <div> | |
| <label class="block text-sm font-semibold text-slate-700 mb-2">粘贴生数据</label> | |
| <textarea id="rawInput" rows="12" placeholder="粘贴邮箱地址(支持逗号、空格、分号、换行等任意分隔符)..." oninput="updateRawCount()" class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm font-mono resize-y"></textarea> | |
| <div id="rawCount" class="text-xs text-slate-400 mt-1"></div> | |
| </div> | |
| <div class="flex items-center gap-4"> | |
| <button onclick="processData()" id="processBtn" class="bg-blue-600 text-white px-8 py-3 rounded-xl hover:bg-blue-700 shadow-lg font-bold transition active:scale-95">🔍 整理</button> | |
| <div class="flex items-center gap-3"> | |
| <button onclick="copyResult()" class="bg-emerald-600 text-white px-8 py-3 rounded-xl hover:bg-emerald-700 shadow-lg font-bold transition active:scale-95 hidden" id="copyBtn">📋 复制结果</button> | |
| <button onclick="verifyEmails()" class="bg-amber-600 text-white px-8 py-3 rounded-xl hover:bg-amber-700 shadow-lg font-bold transition active:scale-95 hidden" id="verifyBtn">🔍 DNS验证</button> | |
| </div> | |
| <span id="processStatus" class="text-sm text-slate-500"></span> | |
| </div> | |
| <div id="progressBar" class="hidden mt-2"> | |
| <div class="h-2 bg-slate-200 rounded-full overflow-hidden"> | |
| <div id="progressFill" class="h-full bg-blue-500 transition-all duration-300" style="width:0%"></div> | |
| </div> | |
| <div id="progressText" class="text-xs text-slate-400 mt-1"></div> | |
| </div> | |
| <div id="resultArea" class="hidden mt-4 p-4 bg-slate-50 rounded-xl border border-slate-200"> | |
| <div class="text-sm font-semibold text-slate-700 mb-2">整理结果:</div> | |
| <div id="resultStats" class="text-xs text-slate-500 mb-3 space-y-1"></div> | |
| <textarea id="resultOutput" rows="10" readonly class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm font-mono resize-y bg-white"></textarea> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const BOUNCE_KEY = 'data_bounce_list'; | |
| const GENERIC_PREFIXES = ['info','admin','webmaster','service','jubao','sales','tougao','support','help','noreply','no-reply','mail','tousu','postmaster','abuse']; | |
| function getBounces() { try { return JSON.parse(localStorage.getItem(BOUNCE_KEY) || '[]'); } catch(e) { return []; } } | |
| function saveBounces(list) { localStorage.setItem(BOUNCE_KEY, JSON.stringify(list)); } | |
| async function updateBounceDbCount() { | |
| const token = document.getElementById('adminToken').value.trim(); | |
| if (!token) return; | |
| try { const res = await fetch('/api/crm/bounced_count', { headers: { 'X-Admin-Token': token } }); const data = await res.json(); document.getElementById('bounceCount').textContent = data.count || 0; } catch(e) {} | |
| } | |
| function updateBounceCount() { updateBounceDbCount(); } | |
| function updateRawCount() { | |
| const val = document.getElementById('rawInput').value.trim(); | |
| const count = val ? val.split(/[\n\r]+/).filter(l => l.trim()).length : 0; | |
| document.getElementById('rawCount').textContent = `当前 ${count} 行`; | |
| } | |
| updateBounceCount(); | |
| document.getElementById('bounceFileInput').addEventListener('change', async function(e) { | |
| const files = e.target.files; | |
| if (!files.length) return; | |
| const token = document.getElementById('adminToken').value.trim(); | |
| if (!token) { alert('请先输入 Admin Token'); return; } | |
| let totalAdded = 0; | |
| for (const file of files) { | |
| const text = await file.text(); | |
| const lines = text.replace(/^\ufeff/, '').split(/[\n\r]+/).filter(l => l.trim()); | |
| const emails = []; | |
| for (const line of lines) { | |
| const cleanLine = line.trim(); | |
| if (!cleanLine || cleanLine.startsWith('收信地址')) continue; | |
| const firstCol = cleanLine.split(',')[0].replace(/"/g, '').trim(); | |
| if (firstCol && firstCol.includes('@') && !firstCol.includes(' ')) { emails.push(firstCol); continue; } | |
| if (cleanLine.includes('@') && !cleanLine.includes(' ') && !cleanLine.includes(',')) { emails.push(cleanLine); } | |
| } | |
| if (emails.length > 0) { | |
| await fetch('/api/crm/add_bounced', { method: 'POST', headers: { 'X-Admin-Token': token, 'Content-Type': 'application/json' }, body: JSON.stringify({ emails }) }); | |
| totalAdded += emails.length; | |
| } | |
| } | |
| if (totalAdded > 0) { alert(`已导入 ${totalAdded} 个退信地址到数据库`); updateBounceDbCount(); } | |
| e.target.value = ''; | |
| }); | |
| function clearBounceData() { | |
| if (confirm('确定要清空所有退信记录吗?')) { saveBounces([]); updateBounceCount(); document.getElementById('bounceStatus').textContent = '数据库已记录 0 个退信地址'; } | |
| } | |
| async function processData() { | |
| const raw = document.getElementById('rawInput').value; | |
| const bouncesSet = new Set(getBounces()); | |
| const btn = document.getElementById('processBtn'); | |
| const status = document.getElementById('processStatus'); | |
| const progressBar = document.getElementById('progressBar'); | |
| const progressFill = document.getElementById('progressFill'); | |
| const progressText = document.getElementById('progressText'); | |
| if (!raw.trim()) { status.textContent = '请先粘贴邮箱地址'; status.className = 'text-sm text-red-500'; return; } | |
| btn.disabled = true; btn.textContent = '整理中...'; | |
| progressBar.classList.remove('hidden'); status.textContent = ''; status.className = 'text-sm text-slate-500'; | |
| await sleep(30); | |
| updateProgress(10, '分割行...'); await sleep(20); | |
| const normalized = raw.replace(/[,;,;\s]+/g, '\n'); | |
| const lines = normalized.split(/[\n\r]+/).map(l => l.trim()).filter(l => l); | |
| updateProgress(20, `原始 ${lines.length} 行`); | |
| const validFormat = lines.filter(l => l.includes('@') && !l.includes(' ') && !l.includes('*')); | |
| updateProgress(40, `格式过滤完成,剩余 ${validFormat.length}`); | |
| const notGeneric = validFormat.filter(l => { const p = l.split('@')[0].toLowerCase(); return !GENERIC_PREFIXES.includes(p); }); | |
| updateProgress(55, `通用邮箱过滤完成,剩余 ${notGeneric.length}`); | |
| const unique = [...new Set(notGeneric)]; | |
| updateProgress(70, `去重完成,剩余 ${unique.length}`); | |
| let dbBounces = []; | |
| try { | |
| const token = document.getElementById('adminToken').value.trim(); | |
| if (token) { | |
| const res = await fetch('/api/crm/bounced_check', { method: 'POST', headers: { 'X-Admin-Token': token, 'Content-Type': 'application/json' }, body: JSON.stringify({ emails: unique }) }); | |
| const data = await res.json(); | |
| if (data.bounced) dbBounces = data.bounced; | |
| } | |
| } catch(e) {} | |
| const dbBouncesSet = new Set(dbBounces); | |
| const clean = unique.filter(l => !dbBouncesSet.has(l)); | |
| updateProgress(90, `退信过滤完成,剩余 ${clean.length}`); | |
| const stats = [`原始行数:${lines.length} 条`,`格式过滤:去掉 ${lines.length - validFormat.length} 条`,`通用邮箱:去掉 ${validFormat.length - notGeneric.length} 条`,`本批去重:去掉 ${notGeneric.length - unique.length} 条`,`退信过滤:去掉 ${unique.length - clean.length} 条`,`DNS验证前可用:${clean.length} 条`]; | |
| document.getElementById('resultOutput').value = clean.join('\n'); | |
| document.getElementById('resultStats').innerHTML = stats.map(s => `<div>${s}</div>`).join(''); | |
| document.getElementById('resultArea').classList.remove('hidden'); | |
| document.getElementById('copyBtn').classList.remove('hidden'); | |
| document.getElementById('verifyBtn').classList.remove('hidden'); | |
| updateProgress(100, `完成!最终可用 ${clean.length} 条`); | |
| btn.disabled = false; btn.textContent = '🔍 整理'; | |
| } | |
| async function verifyEmails() { | |
| const token = document.getElementById('adminToken').value.trim(); | |
| if (!token) { document.getElementById('processStatus').textContent = '请先输入 Admin Token'; document.getElementById('processStatus').className = 'text-sm text-red-500'; return; } | |
| const status = document.getElementById('processStatus'); | |
| const resultOutput = document.getElementById('resultOutput'); | |
| const resultStats = document.getElementById('resultStats'); | |
| const verifyBtn = document.getElementById('verifyBtn'); | |
| const emails = resultOutput.value.trim(); | |
| if (!emails) { status.textContent = '没有可验证的邮箱'; status.className = 'text-sm text-red-500'; return; } | |
| verifyBtn.disabled = true; verifyBtn.textContent = '验证中...'; | |
| status.textContent = '正在验证 DNS...'; status.className = 'text-sm text-blue-500'; | |
| try { | |
| const res = await fetch('/api/crm/verify_emails', { method: 'POST', headers: { 'X-Admin-Token': token, 'Content-Type': 'application/json' }, body: JSON.stringify({ emails }) }); | |
| const data = await res.json(); | |
| if (data.success) { | |
| resultOutput.value = data.valid.join('\n'); | |
| resultStats.innerHTML += `<div class="text-red-500">DNS验证:过滤 ${data.invalid_count} 个无效域名</div>`; | |
| const finalCount = data.valid.length; | |
| resultStats.innerHTML += `<div><strong>最终可用:${finalCount} 条</strong></div>`; | |
| status.textContent = `DNS验证完成,${data.valid_count} 个有效,${data.invalid_count} 个无效已过滤`; | |
| status.className = 'text-sm text-emerald-600'; | |
| } else { status.textContent = '验证失败'; status.className = 'text-sm text-red-500'; } | |
| } catch(e) { status.textContent = '网络错误'; status.className = 'text-sm text-red-500'; } | |
| finally { verifyBtn.disabled = false; verifyBtn.textContent = '🔍 DNS验证'; } | |
| } | |
| function copyResult() { | |
| const bouncesSet = new Set(getBounces()); | |
| const raw = document.getElementById('resultOutput').value; | |
| const list = raw.split(/[\n\r]+/).map(l => l.trim()).filter(l => l && l.includes('@')); | |
| const filtered = list.filter(l => !bouncesSet.has(l)); | |
| document.getElementById('resultOutput').value = filtered.join('\n'); | |
| if (!filtered.length) { document.getElementById('processStatus').textContent = '所有邮箱都在退信记录中'; document.getElementById('processStatus').className = 'text-sm text-red-500'; return; } | |
| navigator.clipboard.writeText(filtered.join('\n')).then(() => { document.getElementById('processStatus').textContent = '已复制到剪贴板,现在可以去 CRM 或 SES 页面粘贴发送'; document.getElementById('processStatus').className = 'text-sm text-emerald-600'; }); | |
| } | |
| function updateProgress(pct, text) { document.getElementById('progressFill').style.width = pct + '%'; document.getElementById('progressText').textContent = text; } | |
| function sleep(ms) { return new Promise(r => setTimeout(r, ms)); } | |
| </script> | |
| </body> | |
| </html> |