-
Notifications
You must be signed in to change notification settings - Fork 5
/
update_movedb.py
33 lines (28 loc) · 1.57 KB
/
update_movedb.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
# **************************************************************************** #
# #
# :::::::: #
# update_movedb.py :+: :+: #
# +:+ #
# By: tbruinem <[email protected]> +#+ #
# +#+ #
# Created: 2021/01/02 10:56:07 by tbruinem #+# #+# #
# Updated: 2021/01/08 19:22:23 by tbruinem ######## odam.nl #
# #
# **************************************************************************** #
import pickle
import requests
from lxml import html
movedb = dict()
content = html.fromstring(requests.get('https://wiki.pokemon-vortex.com/wiki/Attackdex').content)
moves = content.xpath('//*[@id=\"mw-content-text\"]/div/table/tbody/*')
for move in moves:
name, movetype, cost, power, acc, category = move.xpath('./*')
# print(name.text, movetype.attrib['class'], cost.text, power.text, acc.text, category.text)
movename = name.text
if not movename:
continue
print(movename[:-1])
movedb[movename[:-1]] = (movetype.attrib['class'], int(power.text))
with open('movedb', 'wb') as f:
pickle.dump(movedb, f, pickle.HIGHEST_PROTOCOL)
print("PokemonVortex movedatabase succesfully updated!, saved under 'movedb'")