Created
December 30, 2019 22:43
-
-
Save giuliano-macedo/78f914f5a87ab9873522019371e09bc4 to your computer and use it in GitHub Desktop.
helper script to get how many matches i have to do so i can get "Variety is the Spice of Life", "The Dedicated" and "The Insane" achievements by scraping paladins-tracker.de for the updated stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup as BS | |
from collections import namedtuple | |
from math import ceil | |
#config | |
lvs=[10,15,20] | |
mean_exp=32000 | |
#---- | |
table=[20000,60000,120000,200000,300000,420000,560000,720000,900000,1100000,1320000,1560000,1820000,2100000,2400000,2720000,3060000,3420000,3800000,4200000] | |
def fix_exp(exp,lvl): | |
if lvl>=20: | |
return float("inf") | |
return exp+table[lvl-1] | |
def how_much_to(exp,desired): | |
return table[desired-1]-exp | |
r=requests.get("https://paladins-tracker.de/player/12867966/champions") | |
soup=BS(r.text,"html.parser") | |
Champion=namedtuple("Champion",["name","lvl","exp"]) | |
champs=[] | |
for champ in soup.select(".player-meta.p-0"): | |
name=champ.select_one("div.float-left>span>b").text | |
clearfix=champ.select("div.clearfix>.float-left") | |
lvl=int(clearfix[1].text.split(":")[1]) | |
exp=fix_exp(int(clearfix[2].text.split(":")[1].replace(",","")),lvl) | |
champs.append(Champion(name,lvl,exp)) | |
for desired in lvs: | |
completed=len([champ for champ in champs if champ.lvl>=desired]) | |
print("for lvl:",desired) | |
print("completed:",completed) | |
print("-"*10) | |
for champ in champs: | |
if champ.lvl>=lvs[-1]: | |
continue | |
print("-"*10) | |
print("champ:",champ.name) | |
print("lvl:",champ.lvl) | |
print(f"exp: {champ.exp:,}") | |
for desired in lvs[::-1]: | |
if champ.lvl>=desired: | |
continue | |
remaining=how_much_to(champ.exp,desired) | |
matches=ceil(remaining/mean_exp) | |
print(f"remaining matches for ({desired}): ~{matches}") | |
print("-"*48) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment