用VBS實現(xiàn)的發(fā)送帶Cookie的HTTP請求的代碼
更新時間:2013年01月14日 00:51:46 作者:
在昨天的《使用正確版本的XMLHTTP》中賣了個關(guān)子,ServerXMLHTTP的功能比XMLHTTP強大,你現(xiàn)在大概已經(jīng)猜到了吧。沒錯,用ServerXMLHTTP可以在HTTP請求頭中加入Cookie,而XMLHTTP不可以
為了方便測試,先寫一個回顯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
相關(guān)文章
視頻轉(zhuǎn)換大師WinMPG Video Convert 6.63
視頻轉(zhuǎn)換大師WinMPG Video Convert 6.63...2007-04-04用VBS實現(xiàn)PHP的md5_file函數(shù)代碼
用VBS實現(xiàn)PHP的md5_file函數(shù)代碼,需要的朋友可以參考下,代碼主要是參考官方的資料。2011-01-01用VBS調(diào)用程序并對程序的運行情況進行監(jiān)控的兩個代碼
用VBS調(diào)用程序并對程序的運行情況進行監(jiān)控的兩個代碼...2007-03-03