看样子 贴代码是有必要的了。高手帮忙看一下吧,其它大部的代码都差不多就是填值,提交网页,但是现在是最后一步的时候 第一步的SESSION不见了
1行: procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
2行: const pDisp: IDispatch; var URL: OleVariant);
3行: var
4行: i:integer;
5行: begin
6行: Doc := WebBrowser1.Document as IHTMLDocument2;
7行: Elements := Doc.Forms as IHTMLElementCollection;
8行: // 1 查询通用网址名称
9行: if ok1 then
10行: begin
11行: Form := Elements.Item(0,varEmpty) as IHTMLFormElement;
12行: Elements := (Doc.All as IHTMLElementCollection).tags('input') as IHTMLElementCollection;
13行: i:=0;
14行: while(i<Elements.length) do
15行: begin
16行: InputElem := Elements.Item(i, varEmpty) as IHTMLInputElement;
17行: memo1.Lines.Add(InputElem.name);
18行: if InputElem.name = 'keyword' then InputElem.value := wz.Text; //输入文字
19行: OkElem := InputElem;
20行: ok1:=false ;
21行: ok2:=true;
22行: i:=i+1;
23行: end;
24行: OkElem.form.submit;
25行: end;
26行:
27行: // 2 判断是否已被注册 被注册的话 再次写入查询的通用网址到OK1 点注册 到OK3
28行: if (ok2) and (pos('以下通用网址',doc.body.innerText)>0) then
29行: begin
30行: if (pos('以下通用网址可注册',doc.body.innerText)=0) then
31行: begin
32行: //不可以注册
33行: ok1 := true ;
34行: ok2 := false ;
35行: WebBrowser1.Navigate('http://www.bizcn.com/keyword');
36行: end
37行: else
38行: begin
39行: ok2 := false;
40行: ok3 := true ;
41行: ok4 := true ; //有的时候 登录过了SESSION还有
42行: Form := Elements.Item(0,varEmpty) as IHTMLFormElement;
43行: Elements := (Doc.All as IHTMLElementCollection).tags('input') as IHTMLElementCollection;
44行: i:=0;
45行: while(i<Elements.length) do
46行: begin
47行: InputElem := Elements.Item(i, varEmpty) as IHTMLInputElement;
48行: if InputElem.value = '注册' then OkElem := InputElem;
49行: memo1.Lines.Add(InputElem.name);
50行: i:=i+1;
51行: end;
52行: OkElem.form.submit; //提交网页
53行: end;
54行: end;
55行: // 3通用网址可以注册了 现在开始注册
56行: if ok3 and (pos('以下的操作必需以用户的身份进入',doc.body.innerHTML)>0) then
57行: begin
58行: ok3 := false ;
59行: ok4 := true ;
60行: Form := Elements.Item(0,varEmpty) as IHTMLFormElement;
61行: Elements := (Doc.All as IHTMLElementCollection).tags('input') as IHTMLElementCollection;
62行: i:=0;
63行: memo1.Lines.Clear;
64行: while(i<Elements.length) do
65行: begin
66行: InputElem := Elements.Item(i, varEmpty) as IHTMLInputElement;
67行: if InputElem.name = 'login_name' then InputElem.value := user.Text;
68行: if InputElem.name = 'password' then InputElem.value := password.Text;
69行: OkElem := InputElem;
70行: memo1.Lines.Add(InputElem.name);
71行: i:=i+1;
72行: end;
73行: OkElem.form.submit;
74行: end;
75行: //填写注册表
76行: if ok4 and (pos('通用网址注册申请表',doc.body.innerHTML)>0) then
77行: begin
78行: ok4 := false ;
79行: ok5 := true ;
80行: Form := Elements.Item(0,varEmpty) as IHTMLFormElement;
81行: Elements := (Doc.All as IHTMLElementCollection).tags('input') as IHTMLElementCollection;
82行: i:=0;
83行: memo1.Lines.Clear;
84行: while(i<Elements.length) do
85行: begin
86行: InputElem := Elements.Item(i, varEmpty) as IHTMLInputElement;
87行: if InputElem.name = 'URL' then InputElem.value := a1.text;
88行: if InputElem.name = 'purpose' then InputElem.value := a2.text;
89行: if InputElem.name = 'admi_ph_city' then InputElem.value := b11.text;
90行: if InputElem.name = 'admi_ph' then InputElem.value := b12.text;
91行: if InputElem.name = 'admi_fax_cc' then InputElem.value := b13.text;
92行: if InputElem.name = 'admi_fax_city' then InputElem.value := b14.text;
93行: if InputElem.name = 'admi_fax' then InputElem.value := b15.text;
94行: if InputElem.name = 'admi_em' then InputElem.value := b16.text;
95行: OkElem := InputElem;
96行: memo1.Lines.Add(InputElem.name);
97行: i:=i+1;
98行: end;
99行: OkElem.form.submit;
100行: end;
101行: // 5 开始结算
102行: if ok5 and (pos('images/ord.gif',doc.body.innerHTML)>0) and (pos('公开价',doc.body.innerHTML)>0) then
103行: begin
104行: ok3 := false ;
105行: ok4 := false ;
106行: ok5 := false ;
107行: ok6 := true ;
108行: Form := Elements.Item(0,varEmpty) as IHTMLFormElement;
109行: Elements := doc.get_links;
110行: i:=0;
111行: memo1.Lines.Clear;
112行: while(i<Elements.length) do
113行: begin
114行: img := Elements.item(i,varempty);
115行: // InputElem := Elements.Item(i, varEmpty) as IHTMLInputElement;
116行: if pos('images/ord.gif',img.innerHTML)>0 then
117行: begin
118行: memo1.Lines.Add(img.href);
119行: break;
120行: end;
121行: i:=i+1;
122行: end;
123行: img.click;
124行: end;
125行: if ok6 and (pos('请选择支付方式',doc.body.innerHTML)>0) and (pos('确定',doc.body.innerHTML)>0) then
126行: begin
127行: if is_test then
128行: begin
129行: Button2.Click;
130行: showmessage('测试通过');
131行: end
132行: else
133行: begin
134行: Form := Elements.Item(0,varEmpty) as IHTMLFormElement;
135行: Elements := (Doc.All as IHTMLElementCollection).tags('input') as IHTMLElementCollection;
136行: i:=0;
137行: memo1.Lines.Clear;
138行: while(i<Elements.length) do
139行: begin
140行: InputElem := Elements.Item(i, varEmpty) as IHTMLInputElement;
141行: if InputElem.name = 'pay' then
142行: OkElem := InputElem;
143行: memo1.Lines.Add(InputElem.name);
144行: i:=i+1;
145行: end;
146行: //showmessage(OkElem.value);
147行: OkElem.form.submit;
148行: end;
149行: end;
150行: end;