Well Kasp, Fizzer is actually wrong. You can automate your spreadsheet theoretically, you just need a way to import the ratings parsed from python into excel/google sheets/whatever.
def getLadderTeamData(teamID, timeout=30):
"""
Returns HTML source for ladder team page
"""
url = "https://www.warlight.net/LadderTeam?LadderTeamID=" + str(teamID)
r = requests.get(url=url, timeout=timeout)
return r.text
def processPoints(dataPointString):
"""
Given a string of the format [day, rank, rating],
generates a list of tuples of the format (point #, day, rank, rating)
"""
pointCounter = 0
dataPoints = list()
for item in dataPointString.split("]"):
pointCounter += 1
item = str(item)
item = item.replace("[", "")
if item[0] == ",": item = item[1:]
# to get rid of the "," at the beginning of most of these
pointData = [int(obj) for obj in item.split(",")]
dataPoints.append((pointCounter, pointData[0], pointData[1],
pointData[2]))
return dataPoints
def getLadderHistory(teamID):
"""
Given a ladder team ID, gets rating and rank history
"""
teamData = getLadderTeamData(teamID)
startPhrase, endPhrase = "Points: [", "]]"
start = teamData.find(startPhrase) + len(startPhrase)
teamData = teamData[start:]
end = teamData.find(endPhrase) - 1
# -1 because we want that second to last "]" still in
teamData = teamData[:end]
return processPoints(teamData)
Edited 11/28/2015 15:39:30