-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube-diff.py
More file actions
65 lines (50 loc) · 1.55 KB
/
Copy pathcube-diff.py
File metadata and controls
65 lines (50 loc) · 1.55 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
# get current list
# get new list
# diff lists
# show new cards
# show replaced cards
import requests
import sys
import bs4
res = requests.get(
'https://magic.wizards.com/en/articles/archive/vintage-cube-cardlist')
soup = bs4.BeautifulSoup(res.text, 'html.parser')
newCards = soup.select('table')[1].select('a')
newCardsList = []
for card in newCards:
newCardsList.append(card.string.rstrip('\n'))
addedCards = []
removedCards = []
with open('cubeList', 'r') as oldCards:
oldCardsList = []
for line in oldCards:
oldCardsList.append(line.rstrip('\n'))
for newCard in newCardsList:
if newCard.rstrip('\n') not in oldCardsList:
addedCards.append(newCard.rstrip('\n'))
for oldCard in oldCardsList:
if oldCard.rstrip('\n') not in newCardsList:
removedCards.append(oldCard.rstrip('\n'))
with open('addedCards', 'w') as f:
for card in addedCards:
f.write(card + '\n')
with open('removedCards', 'w') as f:
for card in removedCards:
f.write(card + '\n')
print("------------\n")
print("added cards: ")
print("------------\n")
print("\n".join(addedCards))
print("------------\n")
print("removed Cards: ")
print("------------\n")
print("\n".join(removedCards))
print("added: " + str(len(addedCards)) + " removed:" + str(len(removedCards)))
#f.write(card.string+ '\n')
proceed = input("do you want to update your cube file? y/n: ")
if proceed == 'n':
exit()
else:
with open('cubeList', 'w') as cubeList:
for card in newCards:
cubeList.write(card.string + '\n')