anyproxy -i -r fxweb.js > test.log
其中fxweb.js内容如下:
var logMap = {} var fs = require('fs'); var logger = fs.createWriteStream(__dirname + '/urlLog.log', { flags: 'a' // 'a' means appending (old data will be preserved) }) function logPageFile(url) { if (!logMap[url]) { logMap[url] = true; logger.write(url + '\r\n'); } } module.exports = { // 模块介绍 summary: 'my customized rule for AnyProxy', // 发送请求前拦截处理 *beforeSendRequest(requestDetail) { if( requestDetail.url.indexOf(".mp4?token=") != -1 ){ logPageFile(requestDetail.url) } }, // 发送响应前处理 *beforeSendResponse(requestDetail, responseDetail) { /* ... */ }, // 是否处理https请求 *beforeDealHttpsRequest(requestDetail) { /* ... */ }, // 请求出错的事件 *onError(requestDetail, error) { /* ... */ }, // https连接服务器出错 *onConnectError(requestDetail, error) { /* ... */ } };