This repository has been archived on 2019-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
basta-server/ofu-food/events/ofu-eventpage-parser.py
2017-09-27 16:24:36 +02:00

26 lines
577 B
Python

import requests
import datetime
import xmltodict
import json
def loadPage(url: str):
return requests.get(url).content
def getDay():
return datetime.datetime.today().strftime("%A, %d.%m.%Y")
def parsePage(url: str):
# {Univis: {'Event':[{,,,,},,,,]}}
page = loadPage(url)
dict = xmltodict.parse(page)
json_data = json.dumps(dict)
json_data = json.loads(json_data)
json_data['last_execute'] = getDay()
return json.dumps(json_data)
# UNIVIS_RPG_URL = "http://univis.uni-bamberg.de/prg?search=events&show=xml"
# parsePage(UNIVIS_RPG_URL)