L
Lu Wei
Hello,
I'm writing a script to send posts to a web forum. I find that
MSXML2.XMLHTTP object could communicate with web server but I can't make
it send cookie which is needed for post authentication. I have searched
google and read some articles including:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q290899
http://support.microsoft.com/kb/234486/en-us
But setting the cookie twice as suggested didn't work. Here is my script:
//log in
var site="bbs.nju.edu.cn";
var body="login string"
var xmlhttp = WScript.CreateObject("MSXML2.XMLHTTP")
xmlhttp.open("POST","http://"+site+"/bbslogin?type=2", false);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(body);
WScript.Echo(xmlhttp.responseText); // log in will succeed
//post request
var _U_NUM, _U_UID, _U_KEY; //cookie names
....// assign values returned by login process to cookie names
xmlhttp.open("GET","http://"+site+"/bbspst?board=test", false);
xmlhttp.setRequestHeader("Cookie", "_U_NUM="+_U_NUM+";
_U_UID="+_U_UID+"; _U_KEY="+_U_KEY+"; FOOTKEY=;");
xmlhttp.setRequestHeader("Cookie", "_U_NUM="+_U_NUM+";
_U_UID="+_U_UID+"; _U_KEY="+_U_KEY+"; FOOTKEY=;");
xmlhttp.send();
WScript.Echo(xmlhttp.responseText); // this request will fail
I used ethereal and confirmed that no "Cookie:" header is sent. Could it
really be done by javascript to post articles to a web forum? What else
could I do? Any help is appreciated.
Some system info: win98se, WSH5.6, msxml.dll version is 8.0.6730.0
I'm writing a script to send posts to a web forum. I find that
MSXML2.XMLHTTP object could communicate with web server but I can't make
it send cookie which is needed for post authentication. I have searched
google and read some articles including:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q290899
http://support.microsoft.com/kb/234486/en-us
But setting the cookie twice as suggested didn't work. Here is my script:
//log in
var site="bbs.nju.edu.cn";
var body="login string"
var xmlhttp = WScript.CreateObject("MSXML2.XMLHTTP")
xmlhttp.open("POST","http://"+site+"/bbslogin?type=2", false);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(body);
WScript.Echo(xmlhttp.responseText); // log in will succeed
//post request
var _U_NUM, _U_UID, _U_KEY; //cookie names
....// assign values returned by login process to cookie names
xmlhttp.open("GET","http://"+site+"/bbspst?board=test", false);
xmlhttp.setRequestHeader("Cookie", "_U_NUM="+_U_NUM+";
_U_UID="+_U_UID+"; _U_KEY="+_U_KEY+"; FOOTKEY=;");
xmlhttp.setRequestHeader("Cookie", "_U_NUM="+_U_NUM+";
_U_UID="+_U_UID+"; _U_KEY="+_U_KEY+"; FOOTKEY=;");
xmlhttp.send();
WScript.Echo(xmlhttp.responseText); // this request will fail
I used ethereal and confirmed that no "Cookie:" header is sent. Could it
really be done by javascript to post articles to a web forum? What else
could I do? Any help is appreciated.
Some system info: win98se, WSH5.6, msxml.dll version is 8.0.6730.0