首页 > 其他分享 >OnBeforeResponse

OnBeforeResponse

时间:2023-11-27 18:38:54浏览次数:28  
标签:OnBeforeResponse sw System filename IO var oSession


static function OnBeforeResponse(oSession: Session) {
		
		//oSession.host 请求的host
		//oSession.url.Contains 请求host之后的字段 https://mp.weixin.qq.com/mp/getappmsgext  C:\Users\Arbor\Desktop
		if(oSession.host == 'mp.weixin.qq.com' && oSession.url.Contains("/mp/getappmsgext")){
			var now = new Date();
			//var ts = now.getTime();
			var timestamp = format(now);
			var fileName = "response"+timestamp+".txt";
			
			var filename = "C:/Users/Arbor/Desktop/"+fileName;
			
			var logContent = oSession.GetResponseBodyAsString();    //oSession.GetResponseBodyAsString()获取相应内容字符串
			var sw : System.IO.StreamWriter;  
			if (System.IO.File.Exists(filename)){  //是否有该文件夹  
				sw = System.IO.File.AppendText(filename);   //有添加
				sw.Write(logContent);  
			}  
			else{  
				sw = System.IO.File.CreateText(filename);  //没有创建
				sw.Write(logContent);  
			}  
			sw.Close();  
			sw.Dispose();  

		}
		
		//这是本身自带的不要做修改
        if (m_Hide304s && oSession.responseCode == 304) {
            oSession["ui-hide"] = "true";
        }
    }

标签:OnBeforeResponse,sw,System,filename,IO,var,oSession
From: https://www.cnblogs.com/Arborblog/p/17860074.html

相关文章