|
|
|
@ -1,20 +1,20 @@
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# wtf jsou tyhle obrovsky mezery
|
|
|
|
|
|
|
|
|
|
def ship_detail(ShipName):
|
|
|
|
|
url = 'https://swapi.co/api/starships'
|
|
|
|
|
r = requests.get(url).json()
|
|
|
|
|
res = r['results']
|
|
|
|
|
ship_absolute = ''
|
|
|
|
|
for ship in res:
|
|
|
|
|
if ship['name'] == ShipName:
|
|
|
|
|
r = requests.get(url).json() # tohle je mega gay, protoze si nacitas vsechny data
|
|
|
|
|
res = r['results'] # a sortujes v pythonu, misto toho abys si upravil
|
|
|
|
|
ship_absolute = '' # url - mel bys to jednodussi, rychlejsi, prehlednejsi
|
|
|
|
|
for ship in res: # a pametove efektivnejsi
|
|
|
|
|
if ship['name'] == ShipName: # lol
|
|
|
|
|
ship_absolute = ship
|
|
|
|
|
break
|
|
|
|
|
return[ship_absolute['name'], ship_absolute['model'], [requests.get(film).json()['title'] for film in ship_absolute['films']]]
|
|
|
|
|
return[ship_absolute['name'], ship_absolute['model'], [requests.get(film).json()['title'] for film in ship_absolute['films']]] # sexy
|
|
|
|
|
|
|
|
|
|
def species_detail(SpeciesName):
|
|
|
|
|
url = 'https://swapi.co/api/species'
|
|
|
|
|
url = 'https://swapi.co/api/species' # stejnej problem jako nahore
|
|
|
|
|
r = requests.get(url).json()
|
|
|
|
|
res = r['results']
|
|
|
|
|
species_absolute = ''
|
|
|
|
@ -25,10 +25,10 @@ def species_detail(SpeciesName):
|
|
|
|
|
list_title = [requests.get(film).json()['title'] for film in species_absolute['films']]
|
|
|
|
|
list_id = [requests.get(film).json()['episode_id'] for film in species_absolute['films']]
|
|
|
|
|
sort = sorted(zip(list_id, list_title))
|
|
|
|
|
return [species_absolute['name'], species_absolute['classification'], species_absolute['designation'], requests.get(species_absolute['homeworld']).json()['name'], sort]
|
|
|
|
|
return [species_absolute['name'], species_absolute['classification'], species_absolute['designation'], requests.get(species_absolute['homeworld']).json()['name'], sort] # sexy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def person_detail(Name):
|
|
|
|
|
def person_detail(Name): # a zase
|
|
|
|
|
url = 'https://swapi.co/api/people'
|
|
|
|
|
r = requests.get(url).json()
|
|
|
|
|
res = r['results']
|
|
|
|
@ -41,9 +41,9 @@ def person_detail(Name):
|
|
|
|
|
list_title = [requests.get(film).json()['title'] for film in person_absolute['films']]
|
|
|
|
|
list_id = [requests.get(film).json()['episode_id'] for film in person_absolute['films']]
|
|
|
|
|
sort = sorted(zip(list_id, list_title))
|
|
|
|
|
return [person_absolute['name'], person_absolute['gender'], requests.get(person_absolute['homeworld']).json()['name'], sort]
|
|
|
|
|
return [person_absolute['name'], person_absolute['gender'], requests.get(person_absolute['homeworld']).json()['name'], sort] # sexy
|
|
|
|
|
|
|
|
|
|
def Crawl(Film_Title):
|
|
|
|
|
def Crawl(Film_Title): # a poctvrte
|
|
|
|
|
url = 'https://swapi.co/api/films'
|
|
|
|
|
r = requests.get(url).json()
|
|
|
|
|
res = r['results']
|
|
|
|
@ -55,7 +55,7 @@ def Crawl(Film_Title):
|
|
|
|
|
print(film_absolute['opening_crawl'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def film_detail(FilmIdentifier):
|
|
|
|
|
def film_detail(FilmIdentifier): # a popate :D
|
|
|
|
|
url = 'https://swapi.co/api/films'
|
|
|
|
|
r = requests.get(url).json()
|
|
|
|
|
res = r['results']
|
|
|
|
@ -66,7 +66,7 @@ def film_detail(FilmIdentifier):
|
|
|
|
|
break
|
|
|
|
|
list_char = [requests.get(char).json() for char in film_absolute['characters']]
|
|
|
|
|
list_ship = [requests.get(char).json() for char in film_absolute['starships']]
|
|
|
|
|
return [film_absolute['title'], film_absolute['director'], film_absolute['episode_id'], sorted([ch['name'] for ch in list_char]), sorted([ch['name'] for ch in list_ship])]
|
|
|
|
|
return [film_absolute['title'], film_absolute['director'], film_absolute['episode_id'], sorted([ch['name'] for ch in list_char]), sorted([ch['name'] for ch in list_ship])] # sexy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|