IDOMDocument GetXMLWithSession(sUrl,sMethod,vDat)
获取一个带Session的XML文档
+参数列表
sUrl 目标URL
sMethod 获取方式,POST or GET
vData 发送的数据
*只能用同步方式获取
调用本函数之前需要注册字符串转换相关的VBScript函数
*****************************************************************************************/
function GetXMLWithSession(sUrl,sMethod,vData,iMode)
{
var r=/(ASPSESSION.*)\=([^\;\&]*)/ig;
r.exec(document.cookie);
var xmlHttp=CreateHTTPPoster();
xmlHttp.open(sMethod,sUrl,false);
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
xmlHttp.setRequestHeader("Connection", "Keep-Alive");
xmlHttp.setRequestHeader("Accept", "*/*");
xmlHttp.setRequestHeader("Accept-Language", "zh-cn");
xmlHttp.setRequestHeader("Referer", window.top.location.href);
xmlHttp.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3215; .NET CLR 1.0.3705)");
xmlHttp.setRequestHeader(RegExp.$1,RegExp.$2);
xmlHttp.send(URLEncoding(vData));
if(xmlHttp.status!=200){
if(xmlHttp.status==404){
xmlHttp=null;
throw new Error('请求的应用程序不存在');
}
if(xmlHttp.status==500){
xmlHttp=null;
throw new Error('请求的应用程序发生内部错误');
}
xmlHttp=null;
throw new Error('发生未知错误,错误类型为 '+xmlHttp.status.toString());
}else{
if(iMode==1) return xmlHttp.responseBody;
var xmlDom=CreateXMLParser();
xmlDom.async=false;
xmlDom.loadXML(Bytes2BSTR(xmlHttp.responseBody));
xmlHttp=null;
if(xmlDom.parseError.errorCode!=0){
throw new Error("返回XML结果格式错误:"+xmlDom.parseError.reason);
}else{
return xmlDom.documentElement;
}
}
}

解决方案 »

  1.   

    在里面oBao.open("POST","http://vivi.sina.com.cn/collect/icollect_ok.php",false);这一行,为什么换成本地地址就可以,远程地址却提示没有权限呢?改如何解决呢?
    ===================
    和IE安全设置有关系oBao.setRequestHeader("Referer","http://www.***.com")这一行为什么提交后抓到的数据包中referer那一项并没有变化呢?
    ====================
    这个问题比较复杂,你在多试验几次还有,可以自己提交一个COOKIE吗?
    ==============================
    Cookie只是一个RequestHeader,你可以自己构造一个Header
      

  2.   

    我看到一个地方用了这种格式:oBao.open("POST","_blank> http://vivi.sina.com.cn/collect/icollect.php",false);
    那个_blank>是什么意思
      

  3.   

    我的目的就是把下面这一堆:pid=&from=&title=%28%B4%A6%C5%AE%B5%DA%D2%BB%B4%CE%29%B7%E1%B7%E1%C2%FA%C2%FA%C6%AF%C6%AF%C1%C1%C1%C1+-%3E+kenter%C1%EC%D3%F2&url=http%3A%2F%2Fbbs.kun163.com%2Fviewthread.php%3Ftid%3D432%26fpage%3D5&desc=&selectmenu=%D0%C2%CE%C5&tag=%C6%E4%CB%FB&ispub=1&Submit2=%CA%D5%B2%D8%B5%BD%D0%C2%C0%CBViVi
    提交到http://vivi.sina.com.cn/collect/icollect.php
      

  4.   

    那用这个oBao.open("POST","http://vivi.sina.com.cn/collect/icollect_ok.php?str="+pid,false)不就过去了吗?
    至于你说过不去,你可能是安全性问题吧!
      

  5.   

    oBao.open("POST","http://vivi.sina.com.cn/collect/icollect_ok.php?str="+pid,false)
    这一行看不太懂,能给结实一下吗