用VBS实现的发送带Cookie的HTTP请求的代码
程序员文章站
2022-08-27 15:55:38
为了方便测试,先写一个回显cookie的简单的php程序: 复制代码 代码如下: $valu...
为了方便测试,先写一个回显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的网页就不用愁了。
原文:
复制代码 代码如下:
<?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的网页就不用愁了。
原文: