Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Login e raspagem do nome no SIGA da Fatec
const request = require('request-promise-native')
const cheerio = require('cheerio')
const login = ({user, pass}) => {
let options = {
method: 'POST',
uri: 'https://siga.cps.sp.gov.br/aluno/login.aspx',
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'https://siga.cps.sp.gov.br'
},
strictSSL: false,
form: {
'vSIS_USUARIOID': user,
'vSIS_USUARIOSENHA': pass,
'GXState': '{"_EventName":"EENTER.","_EventGridId":"","_EventRowId":"","MPW0005_CMPPGM":"login_top.aspx","MPW0005GX_FocusControl":"","vREC_SIS_USUARIOID":"","GX_FocusControl":"vSIS_USUARIOID","GX_AJAX_KEY":"0BDD4711481AA1585555288A38D54A0E","AJAX_SECURITY_TOKEN":"60D2197ED30EA865BA4DDC1181C00E9DE327E1CD49D496228104BEF231E87A2D","GX_CMP_OBJS":{"MPW0005":"login_top"},"sCallerURL":"","GX_RES_PROVIDER":"GXResourceProvider.aspx","GX_THEME":"GeneXusX","_MODE":"","Mode":"","IsModified":"1"}'
},
params: {
'165c97fac0d4c1ad6055e3730b7af070,,gx-no-cache': 1513131652687,
}
}
return request(options)
}
const getNome = (data) => {
return login(data).then(html => console.log(html)).catch((err) => {
if (err.statusCode === 303) {
return request({
method: 'GET',
uri: 'https://siga.cps.sp.gov.br/aluno/' + err.response.headers['location'],
headers: {
'Cookie': err.response.headers['set-cookie'].join(';')
},
strictSSL: false,
}).then(html => {
const $ = cheerio.load(html)
return $('#span_MPW0039vPRO_PESSOALNOME').text()
})
}
})
}
getNome({
user: '',
pass: ''
}).then((teuNome) => {
console.log(teuNome)
})
@raysouza

This comment has been minimized.

Copy link

@raysouza raysouza commented Jul 16, 2018

oi, pode me ajudar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.