nodejs模塊demo: request-promise-native tough-cookie

 

var rp=require('request-promise-native');
var tough=require('tough-cookie');

//創建一個jar能夠本身處理些事務,tough-cookie 能夠用jar._jar進行訪問
//能夠有store參數,不過一直不會用
var jar=rp.jar();

async function test() {
    //訪問百度使用完整模式,否者只有相應的body
    var b=await  rp.get({url:'http://www.baidu.com',jar:jar,resolveWithFullResponse:true});

    //內部的cookiejar能夠訪問
    var k=JSON.stringify(jar._jar.toJSON());

}

test()
相關文章
相關標籤/搜索