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