下面的搞定,pageindex是第几页,我看那个页面一共有121页,你可以在每次取得结束后自动更新下一页继续
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls,mshtml,ActiveX;
type
TForm1 = class(TForm)
Button1: TButton;
wb: TWebBrowser;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure wbDocumentComplete(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
private
{ Private declarations }
surl:string;
pageindex:integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
pageindex:=1;
surl:='http://www.jjedu.com.cn/bigclass.asp?ClassType=2&search_word=&page='+inttostr(pageindex);
wb.Navigate(surl);
end;
procedure TForm1.wbDocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
ng
levariant;
element:IHTMLElement;
row:HTMLTableRow;
tb:IHTMLTable;
all: IHTMLElementCollection;
cell:HTMLTableCell;
i,j:integer;
begin
if url=surl then
begin
all:=IHTMLElementCollection(IHTMLDOCUMENT2(wb.Document).body.all);
j:=0;
for i:=0 to all.length-1 do
if (SUCCEEDED(all.item(i,0).QueryInterface(IHTMLElement,element))) and
(element.id='newsGrid') and
(SUCCEEDED(all.item(i,0).QueryInterface(IHTMLTable, tb)) ) then
begin
for j:=1 to tb.rows.length-1 do
if (SUCCEEDED(tb.rows.item(j,0).QueryInterface(IHTMLTableRow, row))) and
(SUCCEEDED(row.cells.item(1,0).QueryInterface(HTMLTableCell, cell)) ) then
ListBox1.Items.Add(cell.outerText);
end;
//这里更新下一页
end;
end;
end.