Browse Source

- The start of a better parser using bulbapedia

main
Quildra 1 year ago
parent
commit
279bce7b3a
  1. 19
      Utilities/DetermineOriginGame.py

19
Utilities/DetermineOriginGame.py

@ -426,7 +426,7 @@ def is_event_pokemon(pokemon_name, cache):
return False
def get_locations_from_bulbapedia(pokemon_name, cache):
def get_locations_from_bulbapedia(pokemon_name, form, cache):
page_data = get_pokemon_data_bulbapedia(pokemon_name, cache)
if not page_data:
return None
@ -487,6 +487,21 @@ def get_locations_from_bulbapedia(pokemon_name, cache):
game_locations[game.get_text(strip=True)] = location.get_text()
print(f'{game.get_text(strip=True)}: {location.get_text()}')
events_section = soup.find('span', id='In_events')
if events_section:
event_header = events_section.parent
tables = {}
variant = ""
for sibling in event_header.find_next_siblings():
if sibling.name == 'h4':
break
if sibling.name == 'h5':
variant = sibling.get_text(strip=True)
if sibling.name == 'table':
tables[variant] = sibling
for variant in tables:
print(variant)
return game_locations
@ -507,7 +522,7 @@ def check_alternative_sources(pokemon, cache):
if event_status:
return "Event", "Event"
bulb_locations = get_locations_from_bulbapedia(pokemon['base_name'], cache)
bulb_locations = get_locations_from_bulbapedia(pokemon['base_name'], pokemon['form'], cache)
if bulb_locations:
return bulb_locations[0], "Bulbapedia"

Loading…
Cancel
Save