Created
          December 13, 2017 02:43 
        
      - 
      
 - 
        
Save filipemeneses/1ee2021a52e05a6b363cf4786e4be8c3 to your computer and use it in GitHub Desktop.  
    Login e raspagem do nome no SIGA da Fatec
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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) | |
| }) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
oi, pode me ajudar