wafernode抓取网页没有返回值,求指教
发布于 7 年前 作者 sujie 13083 次浏览 来自 问答

抓取访问网页空值啊

const router = require(‘koa-router’)({

prefix: ‘/weapp’

})

var _fn,_fn1

https = require(‘https’)

router.get(’/user/*’, function (req, next){

var path = “in_theaters”;

_fn.getData(path, function (data) {

req.response.body = data  //浏览器显示不了

});

})

_fn = {

getData: function (path, callback) {

https.get(   //是不是这里的问题呢

{

hostname: www.baidu.com,

path: ‘’

}, function (res) {

var body = [];

res.on(‘data’, function (chunk) {

body.push(chunk);

});

res.on(‘end’, function () {

body = Buffer.concat(body);

callback(body.toString())

})

}

)

}

}

module.exports = router

回到顶部