You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
982 B

from bs4 import BeautifulSoup
import requests
def get_pokemons(url):
pokemon_lst = []
response = requests.get(url)
soup = BeautifulSoup(response.text, "lxml")
for row in scraper.find_all("tr")[1:]:
data = row.find_all("td")[1:]
name = data[0].text
number = int(data[1].text)
coordinates = map(float, data[2].text.split(","))
location = Location(*coordinates)
cp = int(data[3].text)
level = int(data[4].text)
attack = int(data[5].text)
defense = int(data[6].text)
hp = int(data[7].text)
iv = int(data[8].text.rstrip("%"))
shiny = data[9].text == "Yes"
start_time = datetime.fromisoformat(data[10].text)
end_time = datetime.fromisoformat(data[11].text)
country = data[12].text
pokemon = Pokemon(name, number, location, cp, level, attack, defense, hp, iv, shiny, start_time, end_time, country)
pokemon_lst.append(pokemon)