node.js 中国天气预报 简单实现
时间:2021-05-30 08:44:14|栏目:NodeJS|点击: 次
复制代码 代码如下:
var request = require('request')
var url = 'http://www.baidu.com/home/xman/data/superload'
var cookie = '你登录百度后的cookie'
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);
var url = 'http://www.baidu.com/home/xman/data/superload'
var cookie = '你登录百度后的cookie'
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);
上一篇:在node.js中怎么屏蔽掉favicon.ico的请求
栏 目:NodeJS
本文标题:node.js 中国天气预报 简单实现
本文地址:http://www.codeinn.net/misctech/131578.html