Skip to main content
JavaScript

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
12 months ago
README.md

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:

  1. Go to https://tracker.gg/bf6
  2. Search for your gamertag/username
  3. Copy the full URL from your browser (it will look like https://tracker.gg/bf6/profile/1234567890/overview)
  4. 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 hours
  • 0 0 * * 0 - Every Sunday at midnight
  • 0 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 processes
  • pm2 logs bf6-scraper - View logs
  • pm2 stop bf6-scraper - Stop the scraper
  • pm2 restart bf6-scraper - Restart the scraper
  • pm2 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 here
  • scraper.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.js with 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 scrape again

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! ๐ŸŽฎ