浏览器 F12 快捷实现指定接口访问

看了一个脚本,里面有一个接口,想要直接获取这个接口的信息,但需要认证。

因为不想再去找人确认实际的接口信息,就直接登录对应的网站,打开F12,在控制台打开如下接口,即可获取指定接口的返回内容

前提是因为接口需要认证后才可访问,所以需要先在F12打开【开发者工具(Developer Tools)】的【Memory】

找到【Application】里的【Storage -> Local storage -> 对应域名的本地存储,找到认证所需要的key】

如下示例使用的认证key为token

const token = localStorage.getItem('token');
if (!token) {
  console.error('localStorage 中未找到 token!');
} else {
  fetch('https://xxx/xxx/configs', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    }
  })
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(e => console.error(e));
}

  

posted @ 2026-08-19 10:30  人间春风意  阅读(5)  评论(0)    收藏  举报