-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-debug-scraper.js
More file actions
42 lines (34 loc) · 1.04 KB
/
run-debug-scraper.js
File metadata and controls
42 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { spawn } = require('child_process');
const fs = require('fs');
console.log('🚀 Starting debug scraper run...');
// Run the scraper and capture output
const scraper = spawn('node', ['webScraping.js'], {
cwd: __dirname,
stdio: ['pipe', 'pipe', 'pipe']
});
let output = '';
let lineCount = 0;
const maxLines = 100; // Show first 100 lines
scraper.stdout.on('data', (data) => {
const lines = data.toString().split('\n');
lines.forEach(line => {
if (lineCount < maxLines) {
console.log(line);
lineCount++;
output += line + '\n';
}
});
if (lineCount >= maxLines) {
console.log(`\n📋 ... (showing first ${maxLines} lines, full output captured)`);
scraper.kill();
}
});
scraper.stderr.on('data', (data) => {
console.error('STDERR:', data.toString());
});
scraper.on('close', (code) => {
console.log(`\n🏁 Scraper exited with code ${code}`);
// Save full output to file for analysis
fs.writeFileSync('debug-output.log', output);
console.log('💾 Full output saved to debug-output.log');
});