用DELPHI WEBBROWSER从网页上拉数据
请教一下,我想从网页上拉数据,我使用以下语句
ovTable:=webbrowser1.OleObject.Document.all.tags('TABLE').item(0);//取表格集合
可以得到表格的所有数据,但把它放到循环中:
url:='http://data.eastmoney.com/bbsj/201112/yjbb.html';
for k:=1 to 10 do begin
if k=1 then
urltxt:=url
else
urltxt:=copy(url,1,length(trim(edit1.Text))-5)+'/ggrq/'+inttostr(k)+'.html';
webbrowser1.Navigate(WideString(UrlTxt), Flags, Flags, Flags, Flags);
while (not docdowncomp) do
Application.ProcessMessages ;
try
ovTable:=webbrowser1.OleObject.Document.all.tags('TABLE').item(0);
except
on e:exception do
showmessage(e.Message);
end;
for i := 1 to (ovTable.Rows.Length - 1) do //循環行
begin
for j := 1 to (ovTable.Rows.Item(i).Cells.Length ) do begin// 循環列
application.ProcessMessages;
memo1.lines.add(ovTable.Rows.Item(i).Cells.Item(j-1).InnerText);
end;
end;
end;
得到的数据全部是第一页的表格数据,第二页又是首页的数据,网页都能成功打开,不知道为什么?