网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 用VBS实现的发送带Cookie的HTTP请求的代码
内容
    在昨天的《使用正确版本的XMLHTTP》中卖了个关子,ServerXMLHTTP的功能比XMLHTTP强大,你现在大概已经猜到了吧。没错,用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的网页就不用愁了。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/13 9:14:03