且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于受密码保护的网站的nodejs Web抓取工具

更新时间:2022-06-03 02:24:44

您不应使用.get而是.post并在通话中添加post参数(用户名和密码)

you shouldn't use .get but .post and put the post param (username and password) in your call

request.post({
  headers: {'content-type' : 'application/x-www-form-urlencoded'},
  url:     url,
  body:    "username=myuser&password=mypw&submit=Login"
}, function(error, response, html){
    //do your parsing... 
    var $ = cheerio.load(html)
});