- Add backend stale process monitoring API (/api/stale-processes) - Add users management route - Add frontend landing page and stale process monitor UI on /scraper-tools - Move old development scripts to backend/archive/ - Update frontend build with new features 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import { readFileSync } from 'fs';
|
|
import { Pool } from 'pg';
|
|
|
|
const pool = new Pool({
|
|
connectionString: 'postgresql://sail:password@localhost:5432/dutchie_menus'
|
|
});
|
|
|
|
async function importProxies() {
|
|
try {
|
|
console.log('📥 Reading proxy list from file...\n');
|
|
|
|
const proxyFile = '/home/kelly/Downloads/proxyscrape_premium_http_proxies.txt';
|
|
const fileContent = readFileSync(proxyFile, 'utf-8');
|
|
const lines = fileContent.trim().split('\n');
|
|
|
|
console.log(`Found ${lines.length} proxies in file\n`);
|
|
|
|
let imported = 0;
|
|
let duplicates = 0;
|
|
let errors = 0;
|
|
|
|
for (const line of lines) {
|
|
const trimmed = line.trim();
|
|
if (!trimmed) continue;
|
|
|
|
const [host, portStr] = trimmed.split(':');
|
|
const port = parseInt(portStr);
|
|
|
|
if (!host || !port) {
|
|
console.log(`❌ Invalid format: ${trimmed}`);
|
|
errors++;
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
// Insert proxy without testing (set active = false initially)
|
|
const result = await pool.query(`
|
|
INSERT INTO proxies (host, port, protocol, active)
|
|
VALUES ($1, $2, 'http', false)
|
|
ON CONFLICT (host, port, protocol) DO NOTHING
|
|
RETURNING id
|
|
`, [host, port]);
|
|
|
|
if (result.rows.length > 0) {
|
|
imported++;
|
|
if (imported % 100 === 0) {
|
|
console.log(`📥 Imported ${imported} proxies...`);
|
|
}
|
|
} else {
|
|
duplicates++;
|
|
}
|
|
} catch (error: any) {
|
|
console.log(`❌ Error importing ${host}:${port}: ${error.message}`);
|
|
errors++;
|
|
}
|
|
}
|
|
|
|
console.log('\n✅ Import complete!');
|
|
console.log('─'.repeat(60));
|
|
console.log(`Imported: ${imported}`);
|
|
console.log(`Duplicates: ${duplicates}`);
|
|
console.log(`Errors: ${errors}`);
|
|
console.log('─'.repeat(60));
|
|
|
|
// Show final count
|
|
const countResult = await pool.query('SELECT COUNT(*) as total FROM proxies');
|
|
console.log(`\n📊 Total proxies in database: ${countResult.rows[0].total}\n`);
|
|
|
|
} catch (error: any) {
|
|
console.error('❌ Error:', error.message);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
importProxies();
|