feat: update geopy

main
Khiem Ton 2 years ago
parent 1025ada7e8
commit fec4dc6d91
Signed by: th4tkh13m
GPG Key ID: 4D9CF147DCADD05D

@ -73,5 +73,9 @@ class Location():
return 117 return 117
else: else:
return 120 return 120
def __repr__(self):
return str(self.latitude) + "," + str(self.longitude)

@ -0,0 +1,21 @@
from geopy.geocoders import Nominatim
from .location import Location
class Player():
def __init__(self):
self.location = None
def set_location_with_query(self, query):
loc = Nominatim(user_agent="GetLoc")
getLoc = loc.geocode(query)
self.location = Location(getLoc.latitude, getLoc.longitude)
def set_location(self, location):
self.location = location
def get_location(self):
return self.location
def cooldown_to(self, location):
return self.location.get_cooldown(location)

@ -1,3 +1,13 @@
class Raid(): class Raid():
def __init__(self): def __init__(self, name, number, level, location, start_time, end_time, country):
pass self.name = name
self.number = number
self.level = level
self.location = location
self.start_time = start_time
self.end_time = end_time
self.country = country
def __repr__(self):
return f"(Raid: {self.name} - {self.level}-star - {self.location} - Start: {self.start_time} - End: {self.end_time})"

@ -1,12 +1,16 @@
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import requests import requests
from .core.pokemon import Pokemon
from .core.raid import Raid
from .core.location import Location
from datetime import datetime
def get_pokemons(url): def get_pokemons(url):
pokemon_lst = [] pokemon_lst = []
response = requests.get(url) response = requests.get(url)
soup = BeautifulSoup(response.text, "lxml") soup = BeautifulSoup(response.text, "lxml")
for row in scraper.find_all("tr")[1:]: for row in soup.find_all("tr")[1:]:
data = row.find_all("td")[1:] data = row.find_all("td")[1:]
name = data[0].text name = data[0].text
@ -28,8 +32,32 @@ def get_pokemons(url):
pokemon = Pokemon(name, number, location, cp, level, attack, defense, hp, iv, shiny, start_time, end_time, country) pokemon = Pokemon(name, number, location, cp, level, attack, defense, hp, iv, shiny, start_time, end_time, country)
pokemon_lst.append(pokemon) pokemon_lst.append(pokemon)
return pokemon_lst
def get_raids():
raid_lst = []
response = requests.get("https://moonani.com/PokeList/raid.php")
soup = BeautifulSoup(response.text, "lxml")
for row in soup.find_all("tr")[1:]:
data = row.find_all("td")
name = data[0].text
number = int(data[1].text)
level = int(data[2].text)
coordinates = map(float, data[3].text.split(","))
location = Location(*coordinates)
start_time = datetime.fromisoformat(data[4].text)
end_time = datetime.fromisoformat(data[5].text)
country = data[6].text
raid = Raid(name, number, level, location, start_time, end_time, country)
raid_lst.append(raid)
return raid_lst

@ -3,28 +3,11 @@ from ispoof.core.location import Location
from ispoof.core.pokemon import Pokemon from ispoof.core.pokemon import Pokemon
from datetime import datetime from datetime import datetime
import requests import requests
from ispoof import scraper
from geopy.geocoders import Nominatim
pokemon_html = requests.get("https://moonani.com/PokeList/index.php") loc = Nominatim(user_agent="GetLoc")
scraper = BeautifulSoup(pokemon_html.text, "lxml") getLoc = loc.geocode("12 Cao Son 7, Da Nang")
for row in scraper.find_all("tr")[1:]: print(type(getLoc.latitude))
data = row.find_all("td")[1:]
name = data[0].text # print(scraper.get_raids())
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)
print(pokemon)

@ -1,4 +1,5 @@
pymobiledevice3 pymobiledevice3
beautifulsoup4 beautifulsoup4
lxml lxml
requests requests
geopy
Loading…
Cancel
Save