0

I am trying to keep track of my statistics inside the game Call of Duty Warzone. I want to be able to update an excel sheet with the new stats I have everyday to keep track of how well I am doing at the game. The hard part I am having is how can I make the program update the stats I have every hour. Are there any tips y'all have to help me?

#imports
from bs4 import BeautifulSoup
import requests
import time
from openpyxl import Workbook

def getWins(URL):
    response = requests.get(URL)
    soup = BeautifulSoup(response.text,'html.parser')
    elems = soup.select('div.giant:nth-child(1) > div:nth-child(1) > div:nth-child(2) > span:nth-child(2)')
    return elems[0].text.strip()

def getKDRatio(URL):
    response = requests.get(URL)
    soup = BeautifulSoup(response.text,'html.parser')
    elems = soup.select('div.giant:nth-child(3) > div:nth-child(1) > div:nth-child(1) > span:nth-child(2)')
    return elems[0].text.strip()

def getDamagePerGame(URL):
    response = requests.get(URL)
    soup = BeautifulSoup(response.text,'html.parser')
    elems = soup.select('div.giant:nth-child(4) > div:nth-child(1) > div:nth-child(1) > span:nth-child(2)')
    return elems[0].text.strip()


URL = 'https://cod.tracker.gg/warzone/profile/battlenet/Anduy%2311113/overview'

for i in range(1,30): #update the excel sheet 30 times
    wins = getWins(URL)
    kdRatio = getKDRatio(URL)
    damagePerGame = getDamagePerGame(URL)

    wb = Workbook() #create the book
    ws = wb.active

    print('Wins: ' + wins)
    print('kdRatio: ' + kdRatio)
    print('damagePerGame: ' + damagePerGame)

    ws['A' + str(i)] = wins #inputs a new cell for every hour
    ws['B' + str(i)] = kdRatio
    ws['C' + str(i)] = damagePerGame
    wb.save('Cod_Tracker.xlsx')
    time.sleep(3600) #update every hour
Marsroverr
  • 556
  • 1
  • 6
  • 23
Anduy
  • 11
  • 1
  • 1
    Welcome to StackOverflow! Please include more details about your problem. What have you tried? What error are you getting? – Marsroverr Jun 22 '20 at 17:24
  • Thank you! sorry for the vagueness. I'm very new at this. So there isn't an error in my code. I guess what I should have asked is 'How can I run this code in the background for a few days to see how my stats change?' – Anduy Jun 22 '20 at 17:27

0 Answers0