作者illl (ill!)
看板Ajax
標題[問題] node用request登入
時間Wed Apr 6 07:20:55 2016
https://www.discogs.com/login?nologin=1&return=%2Fsell%2Fhistory%2F1985784%3F
我想用request(這個
https://github.com/request/request) 登入這個網頁
(登入form的action也是這個網址)
這是我用的code:
request.post({
uri:
"
https://www.discogs.com/login?nologin=1&return=%2Fsell%2Fhistory%2F1985784%3F",
form: {username: "xxxx", password: "yyyy"}
}, function (err, res, body) {
if (err) console.log(err);
console.log(body);
});
不過body還是一樣的頁面
我希望能得到登入後的頁面
https://www.discogs.com/sell/history/1985784
請問我那裏弄錯了?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 108.0.72.181
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Ajax/M.1459898462.A.922.html
1F:推 johnny9144: 我想可能是你node的 sessions 機制沒打開 預設是不啟 04/06 18:43
2F:→ johnny9144: 用,所以你登入後 還是沒有伺服器要的session-cookies 04/06 18:43
3F:→ johnny9144: 可以存取 你多宣告一個 var j = request.jar()試試 04/06 18:43
4F:→ johnny9144: 看 04/06 18:43
5F:→ johnny9144: 然後還有這句 request = request.defaults({jar:j}); 04/06 18:46
6F:→ johnny9144: 剛忘了 ,這樣登入的session-cookies 才會被記得 04/06 18:46
7F:→ johnny9144: 如果還是不行 就要觀察你form 送出的東西 跟他登入的 04/06 18:49
8F:→ johnny9144: 時候送出的 name 是不是一樣 04/06 18:49
9F:→ illl: 感謝回覆 04/07 12:08