procedure TForm1.Button1Click(Sender: TObject); begin WebBrowser1.Navigate('about:blank'); while WebBrowser1.ReadyState < READYSTATE_INTERACTIVE do Application.ProcessMessages; WebBrowser1.OleObject.Document.body.innerHTML := Memo1.Text; end;procedure TForm1.Button2Click(Sender: TObject); var i, j: integer; ovTable: OleVariant; begin //HTML中的第一個Table ovTable := WebBrowser1.OleObject.Document.all.tags('TABLE').item(0); StringGrid1.RowCount := ovTable.Rows.Length ; StringGrid1.ColCount := ovTable.Rows.Item(i).Cells.Length; for i := 0 to (ovTable.Rows.Length - 1) do begin for j := 0 to (ovTable.Rows.Item(i).Cells.Length - 1) do begin StringGrid1.Cells[j,i] := ovTable.Rows.Item(i).Cells.Item(j).InnerText; end; end; end;(注:先把上述网页Html Source放入Memo1.Text、 再準備一個TWebBrowser和TStringGrid控件。 此例只取了第一個Table的内容...)
如果不是,找找,前几天还看到有人问类似的问题;
begin
WebBrowser1.Navigate('about:blank');
while WebBrowser1.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;
WebBrowser1.OleObject.Document.body.innerHTML := Memo1.Text;
end;procedure TForm1.Button2Click(Sender: TObject);
var
i, j: integer;
ovTable: OleVariant;
begin
//HTML中的第一個Table
ovTable := WebBrowser1.OleObject.Document.all.tags('TABLE').item(0);
StringGrid1.RowCount := ovTable.Rows.Length ;
StringGrid1.ColCount := ovTable.Rows.Item(i).Cells.Length; for i := 0 to (ovTable.Rows.Length - 1) do
begin
for j := 0 to (ovTable.Rows.Item(i).Cells.Length - 1) do
begin
StringGrid1.Cells[j,i] := ovTable.Rows.Item(i).Cells.Item(j).InnerText;
end;
end;
end;(注:先把上述网页Html Source放入Memo1.Text、
再準備一個TWebBrowser和TStringGrid控件。
此例只取了第一個Table的内容...)
如果不把这句执行完Webbrowser1.Navigate('http://www.sinam.com');
webbrowser不出现网页就会出错,这是什么原因?
这个问题你从我这里得到答案,还要把分到给你的大鬼qiluping 并又另开了一个贴,以同样题目倒给你的大鬼qiluping
http://community.csdn.net/Expert/topic/3121/3121916.xml?temp=.1097376
qiluping (100)还有以下倒分贴
http://community.csdn.net/Expert/topic/3015/3015031.xml?temp=.588833
qiluping (100)
http://community.csdn.net/Expert/topic/3163/3163549.xml?temp=4.508609E-02
qiluping (40)另外,请你尽快把下贴结了,
http://community.csdn.net/Expert/topic/3122/3122604.xml?temp=.5559961
到现在才发现都是你闹的鬼.否则我也不会客气的,就去下贴,这里已有我的大名了.
http://community.csdn.net/Expert/topic/3071/3071709.xml?temp=.253689