http - SuperAgent -- 仅获取标题
问题描述
我正在使用来自Node.js的超级代理。
对于这样一个简单的请求,我怎样才能只获取/请求页面的标题,而不是完整的内容?
request.get('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
我试图在文档和谷歌中找到,但找不到任何东西。
解决方案
感谢@CBroe 为我指明了正确的方向。
对于来自未来的游客......
您需要用请求替换GET
请求HEAD
。
例如,就我而言,它将是:
const request = require('superagent');
request
.head('https://google.com')
.then((res) => {console.log(res.headers);})
.catch(err=> console.log(err.status));
推荐阅读
- sql - 使用带有重复日期和时间的计数
- r - 使用 ggplot 散布点
- quaternions - 如何使用 DMP MotionApps v4.1 纠正 MPU9250 IMU 中的漂移
- c - 递归函数降序输出
- html - 使用 jsoup 将 html 文本替换为 span
- python - Python RotatingFileHandler 似乎没有旋转日志
- phoenix-framework - Ecto.Repo 检查 id 是否存在于数据库中,Phoenix 框架
- angular5 - 选项卡关闭角度 5 时的 API 调用
- c++ - 在从给定超类继承的所有类上调用虚函数
- angular - 如何使整个 mat-tab 功能像锚标签