Created
August 13, 2018 20:50
-
-
Save ihavenonickname/112fcead87f3b789580de1aa86d5e03c to your computer and use it in GitHub Desktop.
central do aluno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
from requests import Session | |
from collections import namedtuple | |
Disciplina = namedtuple('Disciplina', 'nome nota semestre') | |
def get_disicplinas(cod_aluno, senha, cod_curso): | |
session = Session() | |
form_login = {'codpessoa': cod_aluno, 'senhabib': senha} | |
session.post('https://aplicweb.feevale.br/aluno/Principal.asp', data=form_login) | |
res = session.get('https://aplicweb.feevale.br/aluno/HistoricoGrade.asp?Curso=' + cod_curso) | |
soup = BeautifulSoup(res.text, 'html.parser') | |
eles = soup.select('tbody.textinho > tr.diminuirFonte') | |
eles = [el.select('td') for el in eles if len(el.select('td')) == 6] | |
# 0. Sem. | |
# 1. Componente Curricular/Disciplina | |
# 2. Créditos | |
# 3. Situação | |
# 4. Media | |
# 5. Periodo Cursado | |
for el in eles: | |
nome = el[1].text.split(' - ')[-1] | |
nota = el[4].text | |
semestre = el[5].text | |
if semestre == '---': | |
semestre = '<não cursado>' | |
elif nota == '0,0': | |
semestre = '<cursando>' | |
yield Disciplina(nome, nota, semestre) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from crawler import get_disicplinas | |
app = Flask(__name__) | |
@app.route('/') | |
def hello(): | |
cod_aluno = request.args.get('cod_aluno') | |
senha = request.args.get('senha') | |
try: | |
disciplinas = list(get_disicplinas(cod_aluno, senha, '4001')) | |
except Exception as ex: | |
return str(ex) | |
return '<br>'.join(x.nome for x in disciplinas) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment