allergene=allergene, zusatzstoffe=zusatzstoffe) if not today and type(next_week) is str: parse_week(url + next_week, canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) return canteen.toXMLFeed() parser = Parser('ostniedersachsen', handler=parse_url, shared_prefix='http://www.stw-on.de') sub = parser.sub('braunschweig', shared_prefix='/braunschweig/essen/menus/') sub.define('mensa1-mittag', suffix='mensa-1', extra_args={'canteentype': 'Mittagsmensa'}) sub.define('mensa1-abend', suffix='mensa-1', extra_args={'canteentype': 'Abendmensa'}) sub.define('mensa360', suffix='360', extra_args={ 'canteentype': 'Pizza', 'this_week': '-2', 'next_week': '-nachste-woche' }) sub.define('mensa2', suffix='mensa-2') sub.define('hbk', suffix='mensa-hbk')
@Source.feed(name='nextWeek', priority=2, hour='9') def nextWeek(self, request): day = (datetime.datetime.now() + 7 * datetime.date.resolution).isocalendar() self.parse_data(week=day[1], year=day[0]) return self.feed.toXMLFeed() parser = Parser(name='halle', version=1.0) Canteen('harzmensa', parser, location=3, needed_title='Harzmensa') Canteen('weinbergmensa', parser, location=5, needed_title='Weinbergmensa') #Canteen('cafebar-weinberg', parser, location=, needed_title='') Canteen('tulpe', parser, location=10, needed_title='Mensa Tulpe') Canteen('heidemensa', parser, location=17, needed_title='Heidemensa') Canteen('burg', parser, location=12, needed_title='Mensa Burg') Canteen('neuwerk', parser, location=9, needed_title='Neuwerk') Canteen('franckesche-stiftungen', parser, location=14, needed_title='Franckesche Stiftungen') #merseburg = parser.sub('merseburg') Canteen('merseburg', parser, location=16, needed_title='Mensa Merseburg', not_halle=True) #Canteen('cafebar-merseburg', merseburg, location=, needed_title=) #dessau = parser.sub('dessau') Canteen('dessau', parser, location=13, needed_title='Mensa Dessau', not_halle=True) koethen = parser.sub('koethen') Canteen('fasanerieallee', koethen, location=7, needed_title='Mensa Köthen') #Canteen('lohmannstrasse', koethen, location=, needed_title=None) #bernburg = parser.sub('bernburg') Canteen('bernburg', parser, location=8, needed_title='Mensa Bernburg', not_halle=True)
allergene[title] = text parse_week(url + this_week, canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) if not today and next_week is True: parse_week(url + '-kommende-woche', canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) if not today and type(next_week) is str: parse_week(url + next_week, canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) return canteen.toXMLFeed() parser = Parser('ostniedersachsen', handler=parse_url, shared_prefix='http://www.stw-on.de') sub = parser.sub('braunschweig', shared_prefix='/braunschweig/essen/menus/') sub.define('mensa1-mittag', suffix='mensa-1', extra_args={'canteentype': 'Mittagsmensa'}) sub.define('mensa1-abend', suffix='mensa-1', extra_args={'canteentype': 'Abendmensa'}) sub.define('mensa360', suffix='360', extra_args={'canteentype': 'Pizza', 'this_week': '-2', 'next_week': '-nachste-woche'}) sub.define('mensa2', suffix='mensa-2') sub.define('hbk', suffix='mensa-hbk') parser.define('clausthal', suffix='/clausthal/essen/menus/mensa-clausthal', extra_args={'next_week': '-kommend-woche'}) sub = parser.sub('hildesheim', shared_prefix='/hildesheim/essen/menus/') sub.define('uni', suffix='mensa-uni') sub.define('hohnsen', suffix='mensa-hohnsen') sub.define('luebecker-strasse', suffix='luebecker-strasse', extra_args={'canteentype': 'Mittagsausgabe'}) parser.sub('suderburg').define('campus', suffix='/suderburg/essen/menus/mensa-suderburg')
) canteen.city = address.group("city").strip().capitalize() pass def load_data(self): # Cache the data for 15 min to not stress the API too much now = datetime.datetime.now() if self._data is None or now - self._data[1] > datetime.timedelta(minutes=15): content = urlopen(self.parser.shared_prefix).read() data = BeautifulSoup(content.decode('utf-8'), 'xml') self._data = (data, now) return self._data[0] parser = Parser('ostniedersachsen', version="1.0", shared_prefix='http://api.stw-on.de/xml/mensa.xml') braunschweig = parser.sub('braunschweig') Canteen('mensa1-mittag', braunschweig, id="101", open_id="2") Canteen('mensa1-abend', braunschweig, id="101", open_id="3") Canteen('mensa360', braunschweig, id="111") Canteen('mensa2', braunschweig, id="105") Canteen('mensa2-cafeteria', braunschweig, id="106") Canteen('hbk', braunschweig, id="120") Canteen('bistro-nff', braunschweig, id="109") Canteen('clausthal', parser, id="171") hildesheim = parser.sub('hildesheim') Canteen('uni', hildesheim, id="150") Canteen('hohnsen', hildesheim, id="160") Canteen('luebecker-strasse', hildesheim, id="153")
if title.isdigit(): zusatzstoffe[title] = text else: allergene[title] = text parse_week(url + this_week, canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) if not today and next_week is True: parse_week(url + "-kommende-woche", canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) if not today and type(next_week) is str: parse_week(url + next_week, canteen, canteentype, allergene=allergene, zusatzstoffe=zusatzstoffe) print(canteen.toXMLFeed()) return canteen.toXMLFeed() parser = Parser("ostniedersachsen", handler=parse_url, shared_prefix="http://www.stw-on.de") sub = parser.sub("braunschweig", shared_prefix="/braunschweig/essen/menus/") sub.define("mensa1-mittag", suffix="mensa-1", extra_args={"canteentype": "Mittagsmensa"}) sub.define("mensa1-abend", suffix="mensa-1", extra_args={"canteentype": "Abendmensa"}) sub.define( "mensa360", suffix="360", extra_args={"canteentype": "Pizza", "this_week": "-2", "next_week": "-nachste-woche"} ) sub.define("mensa2", suffix="mensa-2") sub.define("hbk", suffix="mensa-hbk") parser.define("clausthal", suffix="/clausthal/essen/menus/mensa-clausthal", extra_args={"next_week": "-kommend-woche"}) sub = parser.sub("hildesheim", shared_prefix="/hildesheim/essen/menus/") sub.define("uni", suffix="mensa-uni") sub.define("hohnsen", suffix="mensa-hohnsen") sub.define("luebecker-strasse", suffix="luebecker-strasse", extra_args={"canteentype": "Mittagsausgabe"})
@Source.feed(name="nextWeek", priority=2, hour="9") def nextWeek(self, request): day = (datetime.datetime.now() + 7 * datetime.date.resolution).isocalendar() self.parse_data(week=day[1], year=day[0]) return self.feed.toXMLFeed() parser = Parser(name="halle", version=1.0) Canteen("harzmensa", parser, location=3, needed_title="Harzmensa") Canteen("weinbergmensa", parser, location=5, needed_title="Weinbergmensa") # Canteen('cafebar-weinberg', parser, location=, needed_title='') Canteen("tulpe", parser, location=10, needed_title="Mensa Tulpe") Canteen("heidemensa", parser, location=17, needed_title="Heidemensa") Canteen("burg", parser, location=12, needed_title="Mensa Burg") Canteen("neuwerk", parser, location=9, needed_title="Neuwerk") Canteen("franckesche-stiftungen", parser, location=14, needed_title="Franckesche Stiftungen") # merseburg = parser.sub('merseburg') Canteen("merseburg", parser, location=16, needed_title="Mensa Merseburg", not_halle=True) # Canteen('cafebar-merseburg', merseburg, location=, needed_title=) # dessau = parser.sub('dessau') Canteen("dessau", parser, location=13, needed_title="Mensa Dessau", not_halle=True) koethen = parser.sub("koethen") Canteen("fasanerieallee", koethen, location=7, needed_title="Mensa Köthen") # Canteen('lohmannstrasse', koethen, location=, needed_title=None) # bernburg = parser.sub('bernburg') Canteen("bernburg", parser, location=8, needed_title="Mensa Bernburg", not_halle=True)
@Source.feed(name='nextWeek', priority=2, hour='9') def nextWeek(self, request): day = (datetime.datetime.now() + 7 * datetime.date.resolution).isocalendar() self.parse_data(week=day[1], year=day[0]) return self.feed.toXMLFeed() parser = Parser(name='halle', version=1.0) Canteen('harzmensa', parser, location=3, needed_title='Harzmensa') Canteen('weinbergmensa', parser, location=5, needed_title='Weinbergmensa') #Canteen('cafebar-weinberg', parser, location=, needed_title='') Canteen('tulpe', parser, location=10, needed_title='Mensa Tulpe') Canteen('heidemensa', parser, location=17, needed_title='Heidemensa') Canteen('burg', parser, location=12, needed_title='Mensa Burg') Canteen('neuwerk', parser, location=9, needed_title='Neuwerk') Canteen('franckesche-stiftungen', parser, location=14, needed_title='Franckesche Stiftungen') #merseburg = parser.sub('merseburg') Canteen('merseburg', parser, location=16, needed_title='Mensa Merseburg', not_halle=True) #Canteen('cafebar-merseburg', merseburg, location=, needed_title=) #dessau = parser.sub('dessau') Canteen('dessau', parser, location=13, needed_title='Mensa Dessau', not_halle=True) koethen = parser.sub('koethen') Canteen('fasanerieallee', koethen, location=7, needed_title='Mensa Köthen') #Canteen('lohmannstrasse', koethen, location=, needed_title=None) #bernburg = parser.sub('bernburg') Canteen('bernburg', parser, location=8, needed_title='Mensa Bernburg', not_halle=True)