美文网首页
nodejs request CURl 抓取网页数据

nodejs request CURl 抓取网页数据

作者: 好了伤疤忘了痛_伪全栈 | 来源:发表于2018-04-26 15:59 被阅读0次

Node 利用request获取API、网页数据

本例用于通过微信授权回调code获取UserInfo信息

let request = require('request');
let requestData = '';
let url = `https://api.weixin.qq.com/sns/oauth2/access_token?appid=${config.wx.appid}&secret=${config.wx.secret}&code=${code}&grant_type=authorization_code`;

responsebody = request({
  url: url,
  method: "GET",
  json: true,
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify(requestData)
}, function(error, response, body) {
  if (!error && response.statusCode == 200) {
  return body
  }
});

相关文章

网友评论

      本文标题:nodejs request CURl 抓取网页数据

      本文链接:https://www.haomeiwen.com/subject/oucmlftx.html