nodejs web scraper for password protected website

前端 未结 1 1981
臣服心动
臣服心动 2021-01-03 02:52

I am trying to scrape a website using nodejs and it works perfectly on sites that do not require any authentication. But whenever I try to scrape a site with a form that req

相关标签:
1条回答
  • 2021-01-03 03:33

    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)
    });
    
    0 讨论(0)
提交回复
热议问题