node.js - I want to request an interface using superagent
漂亮男人
漂亮男人 2017-06-19 09:07:53
0
1
749

I want to use superagent to request this interfacehttp://hq.sinajs.cn/list=sh600138. How can I output the returned data on the console? Masters, I am still on it. Kindergarten please answer

漂亮男人
漂亮男人

reply all(1)
黄舟

I took a look at your interface, because Content-Type:application/x-javascript; charset=GBK is not a buffer type, so it cannot be parsed directly, just convert it to buffer.

const request = require('superagent');
request
  .get('http://hq.sinajs.cn/list=sh600138')
  .buffer(true)
  .end((err, res) => {
      console.log(res.text);
  });
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!