def parse_url(url, today=False): canteen = OpenMensaCanteen() # todo only for: Tellergericht, vegetarisch, Klassiker, Empfehlung des Tages: canteen.setAdditionalCharges("student", {"other": 1.5}) document = parse(urlopen(url).read()) global legend regex = "\((?P<name>[\dA-Z]+)\)\s*(?P<value>[\w\s]+)" legend = buildLegend(legend, document.find(id="additives").text, regex=regex) days = ( "montag", "dienstag", "mittwoch", "donnerstag", "freitag", "montagNaechste", "dienstagNaechste", "mittwochNaechste", "donnerstagNaechste", "freitagNaechste", ) for day in days: data = document.find("div", id=day) headline = document.find("a", attrs={"data-anchor": "#" + day}) parse_day(canteen, headline.text, data) return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() document = parse(urlopen(url).read(), 'lxml') days = ('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag') for day in days: data = document.find('div', {'data-day': day}) date = data.attrs['data-date'] parse_day(canteen, date, data) return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() canteen.setAdditionalCharges('student', {'other': 1.5}) document = parse(urlopen(url).read()) for submit in document.find_all('input'): if submit['type'] != 'submit': continue parse_week(url, urlencode({submit['name']: submit['value']}).encode('utf8'), canteen) if today: break return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() document = parse(urlopen(url).read(), 'lxml') days = ('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag') for day in days: data = document.find('div', {'data-day': day}) if data is None: continue date = data.attrs['data-date'] parse_day(canteen, date, data) return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() document = parse(urlopen(url).read(), 'lxml') # todo only for: Tellergericht, vegetarisch, Klassiker, Empfehlung des Tages: canteen.setAdditionalCharges('student', {'other': 1.5}) # unwanted automatic notes extraction would be done in `OpenMensaCanteen.addMeal()` # if we used `LazyBuilder.setLegendData()`, so we bypass it using a custom attribute canteen.legend = parse_legend(document) parse_all_days(canteen, document) return canteen.toXMLFeed()
def parse_url(url, place_class=None, today=False): canteen = OpenMensaCanteen() parse_week(canteen, url, place_class) day = datetime.date.today() old = -1 day += datetime.date.resolution * 7 if not today: parse_week(canteen, '{}?kw={}'.format(url, day.isocalendar()[1]), place_class) day += datetime.date.resolution * 7 while not today and old != canteen.dayCount(): old = canteen.dayCount() parse_week(canteen, '{}?kw={}'.format(url, day.isocalendar()[1]), place_class) day += datetime.date.resolution * 7 return canteen.toXMLFeed()
def parse_url(url, place_class=None, today=False): canteen = OpenMensaCanteen() parse_week(canteen, url, place_class) day = datetime.date.today() old = -1 day += datetime.date.resolution * 7 if not today: parse_week(canteen, '{}?kw={}'.format(url, day.isocalendar()[1]), place_class) day += datetime.date.resolution * 7 while not today and old != canteen.dayCount(): old = canteen.dayCount() parse_week(canteen, '{}?kw={}'.format(url, day.isocalendar()[1]), place_class) day += datetime.date.resolution * 7 return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() # todo only for: Tellergericht, vegetarisch, Klassiker, Empfehlung des Tages: canteen.setAdditionalCharges('student', {'other': 1.5}) document = parse(urlopen(url).read()) global legend regex = '\((?P<name>[\dA-Z]+)\)\s*(?P<value>[\w\s]+)' legend = buildLegend(legend, document.find(id='additives').text, regex=regex) days = ('montag', 'dienstag', 'mittwoch', 'donnerstag', 'freitag', 'montagNaechste', 'dienstagNaechste', 'mittwochNaechste', 'donnerstagNaechste', 'freitagNaechste') for day in days: data = document.find('div', id=day) headline = document.find('a', attrs={'data-anchor': '#' + day}) parse_day(canteen, headline.text, data) return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() # todo only for: Tellergericht, vegetarisch, Klassiker, Empfehlung des Tages: canteen.setAdditionalCharges('student', {'other': 1.5}) document = parse(urlopen(url).read()) global legend regex = '(?P<name>(\d|[A-Z])+)\)\s*' + \ '(?P<value>\w+((\s+\w+)*[^0-9)]))' legend = buildLegend(legend, document.find(id='additives').text, regex=regex) days = ('montag', 'dienstag', 'mittwoch', 'donnerstag', 'freitag', 'montagNaechste', 'dienstagNaechste', 'mittwochNaechste', 'donnerstagNaechste', 'freitagNaechste') for day in days: data = document.find('div', id=day) headline = document.find('a', attrs={'data-anchor': '#' + day}) parse_day(canteen, headline.text, data) return canteen.toXMLFeed()
def parse_url(url, today=False): canteen = OpenMensaCanteen() document = parse(urlopen(url).read(), 'lxml') # todo only for: Tellergericht, vegetarisch, Klassiker, Empfehlung des Tages: canteen.setAdditionalCharges('student', {'other': 1.5}) # unwanted automatic notes extraction would be done in `OpenMensaCanteen.addMeal()` # if we used `LazyBuilder.setLegendData()`, so we bypass it using a custom attribute canteen.legend = parse_legend(document) parse_all_days(canteen, document) return canteen.toXMLFeed()
def _parse_url(sourcepage, filename, place): canteen = OpenMensaCanteen() _from_json(canteen, sourcepage + filename, place) return canteen.toXMLFeed()