光庆,关于sunny控件拦截浏览器器请求获取内容请教

grok 1月前 299

 import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio利用sunny中间件实现拦截并修改网页内容";right=477;bottom=404;border="thin")
winform.add()
/*}}*/

import godking.sunny;
import console;
console.open()
var sunny=godking.sunny();
sunny.callback_http = function(winform,id,msgid,msgtype,mod,url,pid,notice,err){
	// 注意:1、回调函数为线程函数;2、要重新引用godking.sunny
	import godking.sunny	
	import web.json;	
	if msgtype==godking.sunny.msgType.http_request and url="http://10.2.2.6:4000/w/#" {
		//data为目标网页代码(去除不想要的内容后的代码)
		
		var response = godking.sunny.httpResponse(msgid);
		console.dump(response)
		response.setData(data);	//设置返回网页内容为自定义内容	
	}	
}
 
if !sunny.start(2021/*代理端口*/,true/*过滤正文*/,true/*全局代理*/,true/*禁止压缩*/,winform/*传递窗口*/)
..win.msgbox("启动失败")
else 
..win.msgbox("启动成功")
 
winform.onClose = function(hwnd,message,wParam,lParam){//关闭窗口时停止sunny拦截
    sunny.stop();	
}
 
winform.show();
win.loopMessage();

光庆,我想使用你的 sunny 控件来拦截本地浏览器发起的请求,想获取请求的内容和返回的内容,可以实现吗?

还请指点一下。。。

谢谢

最新回复 (2)
返回