-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
95 lines (83 loc) · 2.92 KB
/
main.py
File metadata and controls
95 lines (83 loc) · 2.92 KB
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
import tkinter as tk
import tkinter.messagebox
import win32clipboard
from lxml import html
import requests
import operator
# GUI definition
app = tk.Tk()
app.geometry = ('400x400')
item = tk.StringVar()
entryItem = tk.Entry(app, width=20, textvariable=item)
entryItem.grid(column=2, row=1, padx=10)
def getInfo():
itemName = item.get().splitlines()[1]
chaos={0:0}
exa={0:0}
page = requests.get('https://poedb.tw/tw/xyz.php?rarity=unique&league=Warbands&status=1&name=' + itemName)
tree = html.fromstring(page.content)
text = tree.xpath("//span[@data-name='price']/text()")
print(text)
for x in text:
tmp = x.split('<')
tmp[0] = tmp[0].split('x')[0]
tmp[-1] = tmp[-1].split('>')[-1]
if tmp[-1] == "混沌石":
if tmp[0] not in chaos:
chaos[tmp[0]] = 1
else:
chaos[tmp[0]] = chaos[tmp[0]] + 1
elif tmp[-1] == "崇高石":
if tmp[0] not in exa:
exa[tmp[0]] = 1
else:
exa[tmp[0]] = exa[tmp[0]] + 1
# output the largest amount of entry in market
highestChaos=int(max(chaos.values()))
highestExa=int(max(exa.values()))
if highestChaos>highestExa:
for x in chaos:
if chaos[x] ==highestChaos:
output.set(str(x) + " chaos"+"\n")
else:
for x in exa:
if exa[x]==highestExa:
output.set(str(x) + " exa"+"\n")
def getAllInfo():
output.set('')
chaos={0:0}
exa={0:0}
itemName = item.get().splitlines()[1]
page = requests.get('https://poedb.tw/tw/xyz.php?rarity=unique&league=Warbands&status=1&name=' + itemName)
tree = html.fromstring(page.content)
text = tree.xpath("//span[@data-name='price']/text()")
print(len(text))
text=[''.join(x) for x in zip(text[0::2], text[1::2])]
for x in text:
tmp=x.split('x')
if tmp[-1] == "混沌石":
if tmp[0] not in chaos:
chaos[tmp[0]] = 1
else:
chaos[tmp[0]] = chaos[tmp[0]] + 1
elif tmp[-1] == "崇高石":
if tmp[0] not in exa:
exa[tmp[0]] = 1
else:
exa[tmp[0]] = exa[tmp[0]] + 1
# output all info
for x in chaos:
if x!=0:
output.set(output.get()+str(x)+" chaos: "+str(chaos[x])+"\n")
for x in exa:
if x!=0:
output.set(output.get() + str(x) + " exa: " + str(exa[x]) + "\n")
output = tk.StringVar(app)
buttonReturnName = tk.Button(app, text='Most Common', command=getInfo)
buttonReturnName.grid(column=1, row=2, pady=10)
buttonReturnAllName=tk.Button(app,text='All', command=getAllInfo)
buttonReturnAllName.grid(column=3,row=2,pady=10)
labelResult = tk.Label(app, textvariable=output)
labelResult.grid(column=2, row=3)
# driver function
app.mainloop()