battlefield6-stats-scraper
Automated Battlefield 6 stats tracker from tracker.gg - exports to CSV for historical analysis
- Commits
- 1
- Files
- 7
- Size
- 24.0 KB
- Langs
- 1
- Created
- Nov 2, 2025
- Last push
- 11 months ago
Battlefield 6 Stats Scraper 📊
Automatically track your Battlefield 6 stats from tracker.gg over time. Your stats get saved to a CSV file that grows with each scrape, perfect for tracking your progress!
⚡ Quick Start
1. Install Dependencies
npm install
npx playwright install chromium
2. Configure Your Profile URL
Open config.js and change the profileUrl to your tracker.gg profile:
export default {
// ⚠️ CHANGE THIS TO YOUR PROFILE URL ⚠️
profileUrl: 'https://tracker.gg/bf6/profile/YOUR_ID_HERE/overview',
// ... other settings
};
How to find your tracker.gg URL:
- Go to https://tracker.gg/bf6
- Search for your gamertag/username
- Copy the full URL from your browser (it will look like
https://tracker.gg/bf6/profile/1234567890/overview) - Paste it into
config.js
3. Run It!
One-time scrape:
npm run scrape
Daily automated scraping:
npm run daily
This will:
- Run an immediate scrape when you start it
- Schedule daily scrapes at 9:00 AM (configurable in
config.js) - Keep running in the background
📁 Output
All your data gets saved to the ./data/ directory:
bf6-stats-history.csv- Your stats over time (one row per scrape)screenshot-{timestamp}.png- Screenshots of each scrape (for debugging)
📊 What Stats Are Tracked?
The CSV file includes:
- Profile: Username, Rank Level
- Core Stats: Score/Min, K/D, Win %, Kills/Min, Wins, Losses
- Combat Stats: Headshot %, Damage/Min, Kills, Deaths, Assists, Revives
- Objective Stats: Objective Time %, Objectives Captured/Destroyed
- Class Stats: Time played and KDA for Recon, Assault, Support, Engineer
- Weapons: Top 3 weapons with kill counts
Every time the scraper runs, it adds a new row with your current stats!
⚙️ Configuration
All settings are in config.js:
export default {
// Your tracker.gg profile URL
profileUrl: 'https://tracker.gg/bf6/profile/3176011996/overview',
// When to run (cron format) - default is 9:00 AM daily
// Use https://crontab.guru to create custom schedules
schedule: '0 9 * * *',
// Your timezone
timezone: 'America/New_York',
// Where to save data
dataDir: './data',
// CSV filename
csvFilename: 'bf6-stats-history.csv'
};
Schedule Examples
0 9 * * *- Every day at 9:00 AM (default)0 */6 * * *- Every 6 hours0 0 * * 0- Every Sunday at midnight0 20 * * *- Every day at 8:00 PM
Use crontab.guru to create your own schedule!
🚀 Running 24/7 (Optional)
Want to keep it running even when you close your terminal? Use PM2:
npm install -g pm2
pm2 start scheduler.js --name bf6-scraper
pm2 save
pm2 startup # Follow the instructions to run on system startup
PM2 Commands:
pm2 list- See running processespm2 logs bf6-scraper- View logspm2 stop bf6-scraper- Stop the scraperpm2 restart bf6-scraper- Restart the scraperpm2 delete bf6-scraper- Remove the scraper
📈 Analyzing Your Data
Your bf6-stats-history.csv file can be opened in:
- Excel - Double-click the file
- Google Sheets - File → Import
- Python/R - For custom analysis and charts
🛠️ Files Overview
config.js- ⚠️ Edit this! Set your profile URL herescraper.js- The main scraper (no need to edit)scheduler.js- Daily scheduler (no need to edit)package.json- Dependencies (no need to edit)
❓ Troubleshooting
Problem: "Cannot find profile URL"
- Make sure you edited
config.jswith your tracker.gg URL
Problem: "No stats captured"
- Check the error screenshot in
./data/error-*.png - Your profile might be private or the page structure changed
- Try running
npm run scrapeagain
Problem: "Timeout error"
- tracker.gg might be slow - try running again
- Check your internet connection
📝 License
MIT - Do whatever you want with this!
Made for tracking those BF6 gains! 🎮