华域联盟 vbs 用VBS实现的发送带Cookie的HTTP请求的代码

用VBS实现的发送带Cookie的HTTP请求的代码

为了方便测试,先写一个回显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的网页就不用愁了。

原文:
http://demon.tw/programming/vbs-http-cookie.html
您可能感兴趣的文章:

本文由 华域联盟 原创撰写:华域联盟 » 用VBS实现的发送带Cookie的HTTP请求的代码

转载请保留出处和原文链接:https://www.cnhackhy.com/16342.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部