-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (31 loc) · 1.25 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import requests
from bs4 import BeautifulSoup
from src.url_mapper import urls
from decouple import config
session = requests.Session()
# Faz o login no site
login_data = {
'user.login': config('USER-LOGIN'),
'user.senha': config('USER-PASSWORD')
}
loginRouter = urls['login']
session.post(loginRouter.url, data=login_data)
menuDiscenteRouter = urls['menu_discente']
menu_discente_request = session.get(menuDiscenteRouter.url)
site = BeautifulSoup(menu_discente_request.text, "html.parser")
turmas = site.find(id="turmas-portal")
forms = turmas.find_all('form', id=lambda value: value and 'acessarTurmaVirtualj' in value)
turmas_array = []
for form in forms:
request_payload = {}
form_name = form.get("name")
request_payload['form_acessarTurmaVirtual'] = form_name
idTurma_input = form.find('input', attrs={'name': 'idTurma'})
if idTurma_input:
request_payload['idTurma'] = idTurma_input.get('value')
viewstate_input = form.find('input', attrs={'name': 'javax.faces.ViewState'})
if viewstate_input:
request_payload['javax.faces.ViewState'] = viewstate_input.get('value')
request_payload[form_name + ":turmaVirtual"] = form_name + ":turmaVirtual"
turmas_array.append(request_payload)
print(len(turmas_array))