scarletvioletepokemon.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. import requests
  3. import re
  4. import sys
  5. def pokemondb():
  6. url = "https://pokemondb.net/scarlet-violet"
  7. request = requests.get(url)
  8. if request.status_code != 200:
  9. sys.exit("Could not connect.")
  10. oof_pokemons = re.findall('<a href="/pokedex/.+?">(.*?)</a>', request.text)
  11. pokemons = []
  12. for pokemon in oof_pokemons:
  13. if "\xe9" not in pokemon:
  14. print(pokemon)
  15. pokemons.append(pokemon)
  16. return pokemons
  17. def serebii():
  18. url = "https://www.serebii.net/scarletviolet/pokemon.shtml"
  19. request = requests.get(url)
  20. if request.status_code != 200:
  21. print("Could not connect.")
  22. oof_pokemons = re.findall('<h2><a href="/pokemon/(.+?)><b>(.*?)</b></a></h2>', request.text)
  23. pokemons = []
  24. for pokemon in oof_pokemons:
  25. # tuples
  26. pokemon = pokemon[1]
  27. if pokemon != "???":
  28. print(pokemon)
  29. pokemons.append(pokemon)
  30. return pokemons
  31. if __name__ == '__main__':
  32. pokemondb()
  33. #serebii()