Automatically Export your SI Sportsbook Bet History into CSV format with the Developer Console

While itemizing my wins and losses for my taxes, I needed a way to pull down all my individual bets, with info on the win/loss total and if a free bet was used (as to properly calculate the net win/loss). I ended up using the below JavaScript snippet to get all my bet history output in a CSV format I could copy paste into a text editor or Google Sheet and have a nice bet log.

First some disclaimers: This code could have bugs. This code comes with no warranty or guarantees of accuracy or completeness. This post is only meant to inspire others looking to automate their bet export process on SI Sportsbook.


Disclaimers aside, here’s how I exported my bet history automatically:

1. Navigate to your settled bet history on SI Sportsbook: https://www.sisportsbook.com/bets/settledbets/bs/

2. Copy paste this code block into your Chrome/Edge developer console (I’d usually caution users to be wary of pasting code into their console without knowing what it does, but hopefully those aware enough of the developer console are also aware enough to see this code is benign / read-only.)

rows = []
const timer = ms => new Promise(res => setTimeout(res, ms))
while(true){
    jQuery('.bet-history__bet-single-container').each(function() {
        var bet_type = jQuery(this).find('.bet-history__selection-markets-odds--bet-type').text()
        var event_details = jQuery(this).find('.bet-history__bet-event-details').text()
        var bet_market = jQuery(this).find('.bet-history__selection-markets-odds--selection-name').text()
        var bet_id = jQuery(this).find('.bet-history__place-outcome--bet-details-label:contains("Bet ID")').text().replace("Bet ID:", "")
        var stake = jQuery(this).find('.bet-history__stake--text').text().replace("$", "")
        var payout = jQuery(this).find('.bet-history__returns--amount-win').text().replace("$", "") || "0"
        var is_free_bet = jQuery(this).find('.bet-history__free-bet').length > 0
        var bet_time = jQuery(this).find('.bet-history__place-outcome--placed time:first').attr('datetime')
        var settle_time = jQuery(this).find('.bet-history__place-outcome--placed time:last').attr('datetime')
        console.log(bet_type, event_details, bet_market, bet_id, stake, is_free_bet, payout, bet_time, settle_time)
        d = {
            'bet_type': bet_type,
            'event_details': event_details,
            'bet_market': bet_market,
            'bet_id': bet_id,
            'stake': stake,
            'payout': payout,
            'is_free_bet': is_free_bet,
            'bet_time': bet_time,
            'settle_time': settle_time,
            }
    rows.push(d)
    })
    if(jQuery('.next.disabled').length == 1) { break}
    else {jQuery('.next a')[0].click()}
    await timer(3000); 
}
const dictionaryKeys = Object.keys(rows[0]);

const dictValuesAsCsv = rows.map(d => (
  dictionaryKeys.map(key => {
    if(d[key] && String(d[key]).indexOf(',') > -1) {
      return `"${d[key]}"`;
    }
   
    return d[key];
  }).join(',')
));

const result = [dictionaryKeys.join(','), ...dictValuesAsCsv].join('\n');
console.log(result)

3. Copy the full output of the resulting block of text (which will be in comma delimited format), paste it into your spreadsheet software of choice and “Split Text to Columns” (example of where this shows up for Google Sheets is pictured.)

And that’s it. You can now itemize 100+ bets in a spreadsheet in just a minute.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.