我正在使用Node的超剂。
对于这样简单的请求,我如何只获取/请求页面的标题,而不是完整的内容?
request.get('https://google.com') .then((res) => {console.log(res.headers);}) .catch(err=> console.log(err.status));
我试着在文档和Google中找到,但没有在上面找到任何东西。
发布于 2018-05-09 11:54:34
感谢@CBroe为我指点正确方向。
给来自未来的访客.
您需要的是将GET请求替换为HEAD请求。
例如,在我的例子中,应该是:
const request = require('superagent');
request
.head('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
https://stackoverflow.com/questions/50252091
复制相似问题