removed pasing algorithm + added extra level split

main
Nicolas FRANCO 2 years ago
parent 880135a884
commit 3c3902d570

@ -15,22 +15,6 @@ responseDetails = requests.get(URL)
spellSoup = BeautifulSoup(responseDetails.content, 'lxml')
spellContent = spellSoup.find(id='article-content')
def parseLevelAndGetClass(spell_level):
class_dict = {}
for class_level in spell_level.split(","):
class_level = class_level.strip()
if " " in class_level:
class_name, level = class_level.rsplit(maxsplit=1)
if "/" in class_name:
class_names = class_name.split("/")
for name in class_names:
class_dict[name.strip()] = level.strip()
else:
class_dict[class_name.strip()] = level.strip()
else:
class_dict[class_level.strip()] = "1"
return class_dict
###################
### LEVELS
###################
@ -43,9 +27,6 @@ spell_level = parts[1].replace("Level","").strip().split(";")[0]
print("level: ", spell_level)
print("school: ", spell_school)
class_levels = parseLevelAndGetClass(spell_level)
print(class_levels)
###################
### DESCRIPTION
###################

@ -90,7 +90,7 @@ for li in lis:
text = school_levels.text
parts = text.split("Level")
spell_school = parts[0].replace("School","").strip().strip(";")
spell_level = parts[1].replace("Level","").strip()
spell_level = parts[1].replace("Level","").strip().split(";")[0]
spell_class_and_level = parseLevelAndGetClass(spell_level)
@ -192,7 +192,6 @@ for li in lis:
'effect': spell_effect,
'description': spell_paragraphs
}
break
with open('outputs/spells.yaml', 'w') as f:
yaml.dump(spellz, f)

Loading…
Cancel
Save