用VBS實(shí)現(xiàn)的發(fā)送帶Cookie的HTTP請(qǐng)求的代碼
更新時(shí)間:2013年01月14日 00:51:46 作者:
在昨天的《使用正確版本的XMLHTTP》中賣了個(gè)關(guān)子,ServerXMLHTTP的功能比XMLHTTP強(qiáng)大,你現(xiàn)在大概已經(jīng)猜到了吧。沒錯(cuò),用ServerXMLHTTP可以在HTTP請(qǐng)求頭中加入Cookie,而XMLHTTP不可以
為了方便測試,先寫一個(gè)回顯Cookie的簡單的PHP程序:
<?php
foreach($_COOKIE as $key => $value)
echo "$key => $value\r\n";
?>
然后分別用ServerXMLHTTP和XMLHTTP測試:
Dim http
Set http = CreateObject("Msxml2.XMLHTTP")
http.open "GET", "http://demon.tw/test/cookie.php", False
http.SetRequestHeader "Cookie", "user=demon; passwd=123456"
http.send
WScript.Echo http.responseText
用Msxml2.XMLHTTP什么都沒有返回。
Dim http
Set http = CreateObject("Msxml2.ServerXMLHTTP")
http.open "GET", "http://demon.tw/test/cookie.php", False
http.SetRequestHeader "Cookie", "user=demon; passwd=123456"
http.send
WScript.Echo http.responseText
用Msxml2.ServerXMLHTTP返回
user => demon
passwd => 123456
以后碰到需要Cookie的網(wǎng)頁就不用愁了。
原文: http://demon.tw/programming/vbs-http-cookie.html
復(fù)制代碼 代碼如下:
<?php
foreach($_COOKIE as $key => $value)
echo "$key => $value\r\n";
?>
然后分別用ServerXMLHTTP和XMLHTTP測試:
復(fù)制代碼 代碼如下:
Dim http
Set http = CreateObject("Msxml2.XMLHTTP")
http.open "GET", "http://demon.tw/test/cookie.php", False
http.SetRequestHeader "Cookie", "user=demon; passwd=123456"
http.send
WScript.Echo http.responseText
用Msxml2.XMLHTTP什么都沒有返回。
復(fù)制代碼 代碼如下:
Dim http
Set http = CreateObject("Msxml2.ServerXMLHTTP")
http.open "GET", "http://demon.tw/test/cookie.php", False
http.SetRequestHeader "Cookie", "user=demon; passwd=123456"
http.send
WScript.Echo http.responseText
用Msxml2.ServerXMLHTTP返回
user => demon
passwd => 123456
以后碰到需要Cookie的網(wǎng)頁就不用愁了。
原文: http://demon.tw/programming/vbs-http-cookie.html
您可能感興趣的文章:
- 利用Microsoft.XMLHTTP控件發(fā)送COOKIE
- ASP利用XMLHTTP實(shí)現(xiàn)表單提交以及cookies的發(fā)送的代碼
- AndroidHttpClient使用Cookie應(yīng)用分析
- C# HttpClient Cookie驗(yàn)證解決方法
- .net 獲取瀏覽器Cookie(包括HttpOnly)實(shí)例分享
- httpclient模擬登陸具體實(shí)現(xiàn)(使用js設(shè)置cookie)
- Python模仿POST提交HTTP數(shù)據(jù)及使用Cookie值的方法
- 詳解HTTP Cookie狀態(tài)管理機(jī)制
相關(guān)文章
使用 iisweb.vbs 刪除網(wǎng)站的方法(支持批量刪除)
有時(shí)候我們需要批量刪除網(wǎng)站,如果一個(gè)一個(gè)手工刪除肯定太慢了,這里分享個(gè)命令,通過iisweb.vbs批量刪除網(wǎng)站2014-07-07
VBS基礎(chǔ)篇 - VBScript過程(使用sub 與 Function定義函數(shù))
在 VBScript 中,過程被分為兩類:Sub 過程和 Function 過程,需要的朋友可以參考下2018-05-05
vbs 中調(diào)用shell.application 簡單函數(shù)
vbs實(shí)現(xiàn)的調(diào)用系統(tǒng)命令執(zhí)行的函數(shù),可以根據(jù)用戶選擇運(yùn)行指定的程序2008-06-06
輸入mdb數(shù)據(jù)庫即可將打包的mdb文件解包
2008-01-01
vbscript實(shí)現(xiàn)的根據(jù)不同時(shí)間段顯示不同的歡迎語
頁面加載時(shí),瀏覽器遇到 Script 標(biāo)記。Script 標(biāo)記可能含有 Script 級(jí)代碼(不包含在過程之中),在對(duì) HTML 頁面進(jìn)行語法分析時(shí),將執(zhí)行此代碼。此代碼可使用瀏覽器提供的對(duì)象把內(nèi)容寫入頁面中2013-04-04

