Skip to content

Instantly share code, notes, and snippets.

@gomesar
Last active May 9, 2018 16:24
Show Gist options
  • Save gomesar/0c647534de1dee21eb8e1ab14ce9bc85 to your computer and use it in GitHub Desktop.
Save gomesar/0c647534de1dee21eb8e1ab14ce9bc85 to your computer and use it in GitHub Desktop.
Cardápio diário da Unicamp
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Requires: Pandas
Cardapio do dia da Unicamp
@author: gomesar
2018
'''
from requests import get as rget
from re import sub
from pandas import read_html
_page = rget('https://www.prefeitura.unicamp.br/apps/site/cardapio.php')
page = sub('[\n\t]+[\n\t\ ]*', '', _page.text)
tables = read_html(page)
# table[2:6]
titulos = [ "Almoço", "Almoço Vegetariano", "Jantar", "Jantar Vegetariano" ]
for t in tables[2:6]:
c = "[{}]\n".format(titulos.pop(0))
for i, row in t.iterrows():
if row[0].find('CANECA') == -1:
c += row[0] + '\n'
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment