Unit unit1;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, stdctrls, olectrls, shdocvw;
Type
Tform1 = Class (tform)
Webbrowser1: twebbrowser;
Memo1: tmemo;
Button1: tbutton;
Procedure button1click (Sender: tobject );
*******
{Private Declarations}
Public
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. DFM}
procedure tform1.button1click (Sender: tobject);
var
URL: olevariant;
post: olevariant;
Target: olevariant;
flag: olevariant;
header: olevariant;
poststr: string;
postlen, index: integer;
begin
URL: = 'HTTP: // port.fudan.edu.cn: 58080/amserver/UI/login? Goto = http % 3A % 2f % 2fwww.urp.fudan.edu.cn % 3a81% 2 fepstar % 2fr % 2fpr % 2 fgwkh % 2 fdzgwkh % 2fgr_dzgwkh_index.jsp & gotoonfail = http://www.urp.fudan.edu.cn/portal ?. Flag = fail ';
poststr: = 'login. token1 = 04538 & login. token2 = ******** & submit = % B5 % C7 + % C2 % BC ';
Target: = NULL;
flag: = 0;
postlen: = length (poststr);
// build a variant array of the varbyte type.
post: = vararraycreate ([0, (postlen-1)], varbyte);
// fill in data
for index: = 0 to postlen-1 do
post [Index]: = ord (poststr [index + 1]);
// fill the header data Note: application
header: = 'content-type: application/X-WWW-form-urlencoded ';
Webbrowser1.navigate2 (URL, flag, target, post, header );
While webbrowser1.busy = true do
Application. processmessages;
If webbrowser1.readystate = readystate_complete then
Memo1.text: = webbrowser1.oleobject. Document. All. Tags ('html'). Item (0). outerhtml;
Else
Memo1.text: = 'page loading failed ';
End;
End.