Last active
August 18, 2018 12:31
-
-
Save sovietspy2/37850581225c250601c824b0d50b0ff8 to your computer and use it in GitHub Desktop.
python3 RSS weatcherforcast example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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