Skip to content

Instantly share code, notes, and snippets.

@sovietspy2
Last active August 18, 2018 12:31
Show Gist options
  • Save sovietspy2/37850581225c250601c824b0d50b0ff8 to your computer and use it in GitHub Desktop.
Save sovietspy2/37850581225c250601c824b0d50b0ff8 to your computer and use it in GitHub Desktop.
python3 RSS weatcherforcast example
import feedparser
url = "http://cdn.koponyeg.hu/img/rss/idojaras_rss_regio_4.xml"
def get_actual_weather():
try:
feed = feedparser.parse(url)
# aktualis
telepules = feed['items'][0]['koponyeg_jelenido']['allomas']
homerseklet = feed['items'][0]['koponyeg_jelenido']['homerseklet']
utolso_frissites = feed['items'][0]['koponyeg_jelenido']['datum']
idokep = feed['items'][0]['koponyeg_jelenido']['idokep']
return "Jelenlegi időjárás ({}): hőmérséklet: {} Celsius, időkép: {}, \n utolsó frissítés: {} ".format(telepules, homerseklet, idokep, utolso_frissites)
except Exception:
return "Hiba történt az adatok lekérdezése közben"
teszt = get_actual_weather()
print(teszt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment