-
Notifications
You must be signed in to change notification settings - Fork 0
/
raidstats.py
325 lines (296 loc) · 10.6 KB
/
raidstats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
## TAKP Magelo Ripper
## by Bakastabs
import sys
import datetime
import requests
from bs4 import BeautifulSoup
def main():
print('Pulling Raid Data for:')
#Get Current Date and Format
dt = datetime.datetime.now()
datestring = dt.strftime("%Y-%m-%d")
print(datestring)
#Specify Output File Names and Output Stream
stats_filename = "raidstats_"+datestring+".txt"
items_filename = "items.csv"
original_stdout = sys.stdout # Save a reference to the original standard output
#Declare Output Lists, URLs, Names and Items
stats_output = []
items_output = []
URL = "https://www.takproject.net/magelo/character.php?char="
AAURL = "https://www.takproject.net/magelo/aas.php?char="
names = [
"Scryll",
"Scrylline",
"Lulufoot",
"Concreet",
"Mcsteamy",
"Malfroy",
"Jung",
"Bugg",
"Bibimbap",
"Twose",
"Valerius",
"Biggles",
"Dibs",
"Maddil",
"Plaster",
"Snoppen",
"Flashed",
"Ellasty",
"Princcess",
"Meatza",
"Lorien",
"Greenbean",
"Mordrid",
"Xarik",
"Morbeas",
"Deloyalp",
"Loyal",
"Deloyald",
"Soulfire",
"Succor",
"Soothe",
"Wildlord",
"Dragonfire",
"Ishaa",
"Rarlok",
"Portsn",
"Milesgloriosus",
"Masstransit",
"Marrlowe",
"Lanjar",
"Dolk",
"Ultimum",
"Boreale",
"Echus",
"Brimuk",
"Brimok",
"Brimog",
"Piktonku",
"Pernille",
"Bign",
"Giliath",
"Sren",
"Kenuvas",
"Rakmaz",
"Kelfox",
"Kelfas",
"Kelfious",
"Uflaks",
"Nafse",
"Codesia",
"Cheesefire",
"Daolian",
"Shaolian",
"Beastolian",
"Picks",
"Packs",
"Pokes",
"Almerich",
"Alakron",
"Almeriz",
"Grelrok",
"Grelix",
"Grelwin",
"Vizar",
"Zeah",
"Einaudi",
"Field",
"Jasmin",
"Krex",
"Troutt",
"Sweetie",
"Oprah",
"Mina",
"Burfoot",
"Rast",
"Tassle",
"Lestar",
"Late",
"Boodoo",
"Ganter",
"Foppo",
"Vaeldain",
"Bisben",
"Cisben",
"Disben",
"Kinya",
"Kincla",
"Hogz",
"Hagz",
"Cana",
"Gildarts",
"Mavis",
"Behdet",
"Tierra",
"Estralla",
"Zagio",
"Zagiolita",
"Zagpick",
"Fulgu",
"Dagmentar",
"Nidal",
"Darkz",
"Dyneral",
"Sdcaos",
"Curapupas",
"Batsirai",
"Emnati",
"Quentil",
"Scythe",
"Scythia",
"Immothep"
]
imp_items = [
]
#Pull Data for Each Person
for each in names:
print("Pulling data for "+each)
#Get Base Magelo Data
page = requests.get(URL+each)
soup = BeautifulSoup(page.content, "html.parser")
try:
pr = int(soup.find(class_="player-pr").text)
mr = int(soup.find(class_="player-mr").text)
dr = int(soup.find(class_="player-dr").text)
fr = int(soup.find(class_="player-fr").text)
cr = int(soup.find(class_="player-cr").text)
avg_resist = round((pr+mr+dr+fr+cr)/5,2)
#Create Base Character Output String
line = each
line = line + "," + soup.find(class_="player-class").text
line = line + "," + soup.find(class_="player-hp").text
line = line + "," + soup.find(class_="player-mana").text
line = line + "," + soup.find(class_="player-ac").text
line = line + "," + soup.find(class_="player-atk").text
line = line + "," + str(pr)
line = line + "," + str(mr)
line = line + "," + str(dr)
line = line + "," + str(fr)
line = line + "," + str(cr)
line = line + "," + str(avg_resist)
line = line + "," + each
#Begin items
for item in soup.find_all(class_="ItemTitleMid"):
#print (item)
for compare in imp_items:
#print (compare)
#print (item.text)
if item.text==compare[0]:
#Item Match found add to Output
items_output.append([each,item.text,compare[1]])
#print ("Matched Item")
#begin AA parse
page = requests.get(AAURL+each)
soup = BeautifulSoup(page.content, "html.parser")
AApull = soup.find_all("tr")
AApull.pop(0) #remove first item on list which is the Tab Listing
AApull.pop(0) #remove second item on list which is the entire TR set
#Deal with Output
#init Output Vars
clean_AAs = []
spent_aa_total = 0
unspent_aa_total = 0
resist_aa_total = 0
pr_aa_total = 0
mr_aa_total = 0
dr_aa_total = 0
fr_aa_total = 0
cr_aa_total = 0
def_aa_total = 0
mgb_flag = 0
wood_paragon = 0
radiant_cure = 0
scm = 0
scr = 0
scrm = 0
#generate clean AA list
for row in AApull:
cols = row.find_all("td")
AAname = cols[0].text.strip()
AAval = cols[1].text.strip()
if (AAname != "AA Points:" and AAname != "Points Spent:"):
AAval = AAval.split("/",1)[0]
if AAname != "Title":
clean_AAs.append([AAname, AAval])
#find important AAs
for each in clean_AAs:
name = each[0]
val = int(each[1])
#ugly if statement for all resist AAs
if (name == "Innate Fire Protection" or name == "Warding of Solusek"):
resist_aa_total = resist_aa_total + int(each[1])
fr_aa_total = fr_aa_total + int(each[1])
elif (name == "Innate Cold Protection" or name == "Blessing of E'ci"):
resist_aa_total = resist_aa_total + int(each[1])
cr_aa_total = cr_aa_total + int(each[1])
elif (name == "Innate Magic Protection" or name == "Marr's Protection"):
resist_aa_total = resist_aa_total + int(each[1])
mr_aa_total = mr_aa_total + int(each[1])
elif (name == "Innate Poison Protection" or name == "Shroud of The Faceless"):
resist_aa_total = resist_aa_total + int(each[1])
pr_aa_total = pr_aa_total + int(each[1])
elif (name == "Innate Disease Protection" or name == "Bertoxxulous' Gift"):
resist_aa_total = resist_aa_total + int(each[1])
dr_aa_total = dr_aa_total + int(each[1])
#check defensives
elif (name == "Natural Durability" or name == "Combat Stability" or name == "Combat Agility" or name == "Physical Enhancement" or name == "Lightning Reflexes" or name == "Innate Defense" or name == "Planar Durability"):
def_aa_total = def_aa_total + val
#check for mgb
elif (name == "Mass Group Buff" and val == 1):
mgb_flag = 1
#check wood/paragon
elif (name == "Spirit of the Wood" or name == "Paragon of Spirit"):
wood_paragon = wood_paragon + val
#check radiant cure
elif name == "Radiant Cure":
radiant_cure = radiant_cure + val
#check scm
elif name == "Spell Casting Mastery":
scm = scm + val
#check Spell Casting Reinforcement
elif name == "Spell Casting Reinforcement":
scr = scr + val
elif name == "Spell Casting Reinforcement Mastery":
scrm = scrm + val
#find spent and unspent AAs
elif each[0] == "AA Points:":
unspent_aa_total = int(each[1])
elif each[0] == "Point Spent:":
spent_aa_total = int(each[1])
##Add AA Data to Output
aa_grand_total = spent_aa_total + unspent_aa_total
##print("Spent AAs " + str(spent_aa_total))
##print("Unspent AAs " + str(unspent_aa_total))
##print("Total Resist AAs " + str(resist_aa_total))
##print("Total Fire AAs " + str(fr_aa_total))
##print("Total Cold AAs " + str(cr_aa_total))
##print("Total Magic AAs " + str(mr_aa_total))
##print("Total Poison AAs " + str(pr_aa_total))
##print("Total Disease AAs " + str(dr_aa_total))
line = line + "," + str(aa_grand_total)
line = line + "," + str(spent_aa_total)
line = line + "," + str(unspent_aa_total)
line = line + "," + str(resist_aa_total)
line = line + "," + str(def_aa_total)
line = line + "," + str(mgb_flag)
line = line + "," + str(wood_paragon)
line = line + "," + str(radiant_cure)
line = line + "," + str(scm)
line = line + "," + str(scr+scrm)
#append line to output
stats_output.append(line)
except Exception as e:
print(f"Couldn't process data for {each}. Error: {e}")
#Output to Files
with open(stats_filename, 'w') as f:
sys.stdout = f # Change the standard output to the file we created.
for x in stats_output:
print(x)
with open(items_filename, 'w') as f:
sys.stdout = f # Change the standard output to the file we created.
for each in items_output:
print(each[0] + "," + each[1] + "," + each[2])
sys.stdout = original_stdout # Reset the standard output to its original value
main()