Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Código refatorado e campus Erechim e Passo Fundo estão no ar #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async def ver_cardapio_campus(campus: str, response: Response):
response.status_code = status.HTTP_200_OK
return {'cardapios': cardapio}


@app.get("/campus/{campus}/dia/{dia}")
async def ver_cardapio_campus_dia(campus: str, dia: int, response: Response):
bs = get_cardapio(campus)
Expand Down
8 changes: 6 additions & 2 deletions webscraping/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ def normalize_url(url: str):
def get_cardapio(campus: str):
try:
if campus == 'realeza':
html = urlopen(f"https://www.uffs.edu.br/campi/{normalize_url(campus)}/restaurante_universitario/apresentacao-do-ru")
url = f"https://www.uffs.edu.br/campi/{normalize_url(campus)}/restaurante_universitario/apresentacao-do-ru"
elif campus == 'passo-fundo':
url = f"https://www.uffs.edu.br/campi/{normalize_url(campus)}/restaurante-universitario"
else:
html = urlopen(f"https://www.uffs.edu.br/campi/{normalize_url(campus)}/restaurante_universitario")
url = f"https://www.uffs.edu.br/campi/{normalize_url(campus)}/restaurante_universitario"
html = urlopen(url)

except HTTPError:
return False
if html.code != 200:
Expand Down