Copy the code as follows: var request = require('request')
var url = 'http://www.baidu.com/home/xman/data/superload'
var cookie = 'Cookie after you log in to Baidu'
var options = {
method: "GET",
url: url,
qs: {
"type": "weather",
"asyn": 1,
"t": new Date().getTime()
},
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0',
'Cookie': cookie
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
console.log(info);
}
}
request(options, callback);
When you log in to Baidu, will a weather be displayed? We can use this API to make a small plugin, and there is very little code on it. I hope I can give you a reference and I hope you can support Wulin.com more.