鍍金池/ 問答/人工智能  Linux  HTML/ 模擬登錄總是失敗,為什么一直反回的都是之前取cookie的html?

模擬登錄總是失敗,為什么一直反回的都是之前取cookie的html?

每次用回調(diào)函數(shù)返回html時(shí)都返回的取cookie時(shí)的html,

var request = require('request');

request({

method: 'GET',

url: 'http://202.118.163.67/',

proxy: 'http://neauproxy.feit.me:6000',

followRedirect: false,

},(err,res,html) => {

var cookie = res.headers['set-cookie'][0].split(';')[0];

// console.log(cookie);

 

request({

method: 'POST',

url: 'http://202.118.163.67/index.php',

proxy: 'http://neauproxy.feit.me:6000',

headers:{

'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',

'Accept-Encoding':'gzip, deflate',

'Accept-Language':'zh-CN,zh;q=0.9',

'Cache-Control':'no-cache',

'Content-Length':'63',

'Content-Type':'application/x-www-form-urlencoded',

'Cookie': cookie,

'Host':'202.118.163.67',

'Origin':'http://202.118.163.67',

'Pragma':'no-cache',

'Proxy-Connection':'keep-alive',

'Referer':'http://202.118.163.67/',

'Upgrade-Insecure-Requests':'1',

'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',

 

 

},

form:{

'username':'A02160038',

'password':'19990103',

'Input2':'%E7%99%BB+%E5%BD%95'

}

},(err,res,html)=>{

console.log(html);

});

})
回答
編輯回答
來守候

模擬登錄失敗,檢查下除了cookie外還有沒有額外的驗(yàn)證字段, 而且我發(fā)現(xiàn)你也沒有填referer。推薦你直接把網(wǎng)絡(luò)請(qǐng)求復(fù)制下來,使用發(fā)包工具進(jìn)行測試,成功了再轉(zhuǎn)換成代碼。

至于返回原先的html,自然是目標(biāo)系統(tǒng)設(shè)置好的。

2017年9月28日 07:32