- Reset master to upstream/main (16,697 commits) - Overlay 2,271 local-only files (skills, tools, workspace, configs, apps) - Restore IDENTITY.md and USER.md templates - Build verified, gateway running, Discord working Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Hent vejrdata for byer i Danmark via wttr.in (ingen dependencies)."""
|
|
|
|
import json
|
|
import urllib.request
|
|
|
|
CITIES = ["Copenhagen", "Aarhus", "Odense", "Aalborg"]
|
|
|
|
|
|
def get_weather(city: str) -> dict:
|
|
url = f"https://wttr.in/{city}?format=j1"
|
|
req = urllib.request.Request(url, headers={"User-Agent": "denmark-weather/1.0"})
|
|
with urllib.request.urlopen(req, timeout=10) as resp:
|
|
return json.loads(resp.read())
|
|
|
|
|
|
def main():
|
|
print("=== Vejrdata for Danmark ===\n")
|
|
for city in CITIES:
|
|
try:
|
|
data = get_weather(city)
|
|
cur = data["current_condition"][0]
|
|
temp = cur["temp_C"]
|
|
feels = cur["FeelsLikeC"]
|
|
humidity = cur["humidity"]
|
|
wind_kmph = cur["windspeedKmph"]
|
|
wind_dir = cur["winddir16Point"]
|
|
desc = cur["weatherDesc"][0]["value"]
|
|
precip = cur["precipMM"]
|
|
|
|
print(f" {city}")
|
|
print(f" Temperatur: {temp}°C (føles som {feels}°C)")
|
|
print(f" Forhold: {desc}")
|
|
print(f" Fugtighed: {humidity}%")
|
|
print(f" Vind: {wind_kmph} km/t ({wind_dir})")
|
|
print(f" Nedbør: {precip} mm")
|
|
print()
|
|
except Exception as e:
|
|
print(f" {city}: fejl — {e}\n")
|
|
|
|
print("Kilde: wttr.in")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|