抓取接口
在浏览器控制台 (Console) 直接“监控”数据请求
请你在浏览器中打开 F12,切换到 Console (控制台) 标签,然后粘贴并回车运行下面这段代码:
// 监控所有网络请求并打印出包含 'history' 或数据相关的 URL
(function() {
const originalFetch = window.fetch;
window.fetch = function() {
if(arguments[0].includes('history') || arguments[0].includes('marksix') || arguments[0].includes('api')) {
console.log('%c 找到 Fetch 接口: ', 'background: #222; color: #bada55', arguments[0]);
}
return originalFetch.apply(this, arguments);
};
const originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
if(arguments[1].includes('history') || arguments[1].includes('marksix') || arguments[1].includes('api')) {
console.log('%c 找到 XHR 接口: ', 'background: #222; color: #ff0000', arguments[1]);
}
originalOpen.apply(this, arguments);
};
console.log("监控已启动,请刷新页面或点击年份查看输出...");
})();
运行后,请点击页面上的“2024”年份按钮或者刷新页面。如果它发起了数据请求,控制台会用显眼的颜色把接口地址打印出来。
