import requests
import json
url = "https://api.marinetraffic.com/api/getshipspositions/sid:6720649/v:2/flags:38/zoom:10"
response = requests.get(url)
data = json.loads(response.text)
russian_ships = [ship for ship in data["data"]["positions"] if ship["country"] == "RU"]
for ship in russian_ships:
mmsi = ship.get("mmsi")
lat = ship.get("lat")
lon = ship.get("lon")
course = ship.get("course")
speed = ship.get("speed")
heading = ship.get("heading")
timestamp = ship.get("timestamp")
if mmsi is None or lat is None or lon is None:
continue
print("MMSI:", mmsi)
print("Latitude:", lat)
print("Longitude:", lon)
print("Course:", course)
print("Speed:", speed)
print("Heading:", heading)
print("Timestamp:", timestamp)
print()