import win.ui;
import web.form;
/*DSG{{*/
var winform = ..win.form( bottom=249;right=349;text="aardio Form" )
winform.add( )
/*}}*/
winform.show();
var wb2 = web.form( winform
,0x4/*_UIFLAG_NO3DBORDER*/,,,true/*securityTrusted*/ );
wb2.noScriptErr = true;
wb2.write("loading...")
wb2.go("http://www.baidu.com");
wb2.wait();
import inet;
var cookies = inet.getCookie("http://www.baidu.com");
io.open();
io.print( cookies )
//进入消息循环
win.loopMessage();
return wb,winform;
如果JS里有设置cookie,写的时候格式兼容性没做好,document.cookie 就可能返回为空。
用 inet.getCookie("https://idmsa.apple.com") 可以获取完整的cookies
io.open()
import inet;
for cacheEntry in inet.eachCookie("baidu\.com"){
io.print(
inet.getCookie( cacheEntry.url )
)
}
另外一个获取cookie的方法。
import win.ui;
/*DSG{{*/
var winform = win.form(parent=...; scroll=1;text="aardio Form";right=349;bottom=249 )
winform.add( )
/*}}*/
import web.form;
var wb = web.form(winform);
wb.go("http://www.baidu.com");
winform.show();
wb.wait();
io.open();
io.print("当前 Cookie 为:");
io.print(wb.document.cookie);
io.print();
// 向 Cookie 中加入项目
io.print("现在向 Cookie 中加入项目...");
wb.document.cookie = "a=2";
wb.document.setCookie("b=3"); // 也可以用 setCookie
io.print(wb.document.cookie);
io.print();
// 从 Cookie 中删除项目
io.print("现在从 Cookie 中删除项目...");
var tm = time.now();
tm.addday(-365);
tm.format = "!%a, %d %b %y %H:%M:%S GMT";
wb.document.cookie = "a=deleted;expires=" + tostring(tm);
wb.document.cookie = "b=deleted;expires=" + tostring(tm);
io.print(wb.document.cookie);
win.loopMessage();
return winform,wb;
import inet.whttp
url="http://www.baidu.com"
whttp = inet.whttp()
whttp.beginRequest( url )
whttp.send()
var header = whttp.readHeader()
whttp.endRequest()
io.open()
io.print(header)
io.print("=============================")
for m in string.gmatch( header, "Set-Cookie\:\s(<[^\r\n]+>)") {
io.print(m)
io.print("---------------")
}
import inet.whttp
url="http://www.baidu.com"
whttp = inet.whttp()
whttp.beginRequest( url )
whttp.send()
var header = whttp.readHeader()
whttp.endRequest()
io.open()
io.print(header)
io.print("=============================")
for m in string.gmatch( header, "Set-Cookie\:\s(<[^\r\n]+>)") {
io.print(m)
io.print("---------------")
}
import console;
console.pause();
import inet;
import console;
io.open()
for cacheEntry in inet.eachCookie("baidu.com"){
io.print(cacheEntry.fileName,cacheEntry.url)
}
console.pause();
//多个cookie的获取
主题数 10 | 今日评论 0 | 今日主题 0 |