如果以下则是正常
<tr><td width='10%' class='style8'><a href='disks_smart.php?id=sdi&channel=1&mdname=md1'>1</td><td width='10%' class='style8'>disk1</td><td width='15%' class='style8'>932</td><td width='15%' class='style8'>running</td><td width='10%' class='style8'>md1</td><td width='12%' class='style8'><font color='0000FF'>在用</font></td><td width='20%' class='style8'>ST31000340NS</td></tr>tr里面不是这样的则不正常。
有12个tr标签。=============已经用这个模拟登陆,转到了指定页面
procedure TForm1.btn1Click(Sender: TObject);
var
  strMsg:string;
  response:Tstringstream;
  postlist:tstringlist;
begin
  postlist := TStringlist.create;
  postlist.Clear;
  response := TStringStream.create('');
  idHTP1.HandleRedirects   :=   True;
  postlist.add('username=admin') ;
  postlist.add('password=888888888888') ;
   IdHTP1.Request.ContentType := 'application/x-www-form-urlencoded';
   IdHTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';  try    IdHTP1.post('http://172.29.186.206/login.php',postlist,response)  ;
    postlist.Clear;
    mmo1.Clear;
    response:=nil ;
   //奇怪这里为什么response无法清空,只能mmo1.clear。请指教下
    IdHTP1.post('http://172.29.186.206/disks_info.php',postlist,response)  ;
    mmo1.lines.add(response.DataString);
  finally
    response.Free ;
    postlist.Free;
  end;
end;  事实上最终的结果是要分析100个这样ip。然后统计每个ip地址里面的信息。实时性要求不高,就用for循环一边完了。不用多线程了

解决方案 »

  1.   

    好久不用heml处理了,手边没环境lz看下这个对你有帮助么,取table中的内容的?
    use MSHTML;function GetHtmlTableCell(aTable: IHTMLTable; aRow, aCol: Integer): IHTMLElement;
    var
      Row: IHTMLTableRow;begin
      Result := nil;
      if aTable = nil then Exit;
      if aTable.rows = nil then Exit;
      Row := aTable.rows.item(aRow, aRow) as IHTMLTableRow;
      if Row = nil then Exit;
      Result := Row.cells.item(aCol, aCol) as IHTMLElement;
    end;function GetHtmlTable(aDoc: IHTMLDocument2; aIndex: Integer): IHTMLTable;
    var
      list: IHTMLElementCollection;
    begin
      Result := nil;
      if aDoc = nil then Exit;
      if aDoc.all = nil then Exit;
      list := aDoc.all.tags('table') as IHTMLElementCollection;
      if list = nil then Exit;
      Result := list.item(aIndex,aIndex) as IHTMLTable;
    end;function GetWebBrowserHtmlTableCellText(const AWebBrowser: TWebBrowser;
      const TableIndex, RowIndex, ColIndex: Integer;
      var ResValue: string): Boolean;
    var
      Docintf: IHTMLDocument2;
      tblintf: IHTMLTable;
      node: IHTMLElement;
    begin
      ResValue := '';
      docintf := AWebBrowser.Document as IHTMLDocument2;
      tblintf := GetHtmlTable(docintf, TableIndex);
      node := GetHtmlTableCell(tblintf, RowIndex, ColIndex);
      Result := node <> nil;
      if Result then
        ResValue := Trim(node.innerText);
    end;function GetHtmlTableRowHtml(aTable: IHTMLTable; aRow: Integer): IHTMLElement;
    var
      Row: IHTMLTableRow;
    begin
      Result := nil;
      if aTable = nil then Exit;
      if aTable.rows = nil then Exit;
      Row := aTable.rows.item(aRow, aRow) as IHTMLTableRow;
      if Row = nil then Exit;
      Result := Row as IHTMLElement;
    end;function GetWebBrowserHtmlTableCellHtml(const AWebBrowser: TWebBrowser;
      const TableIndex, RowIndex, ColIndex: Integer;
      var ResValue: string): Boolean;
    var
      Docintf: IHTMLDocument2;
      tblintf: IHTMLTable;
      node: IHTMLElement;
    begin
      ResValue := '';
      docintf := AWebBrowser.Document as IHTMLDocument2;
      tblintf := GetHtmlTable(docintf, TableIndex);
      node := GetHtmlTableCell(tblintf, RowIndex, ColIndex);
      Result := node <> nil;
      if Result then
        ResValue := Trim(node.innerHTML);
    end;
    function GeHtmlTableHtml(aTable: IHTMLTable; aRow: Integer): IHTMLElement;
    var
      Row: IHTMLTableRow;
    begin
      Result := nil;
      if aTable = nil then Exit;
      if aTable.rows = nil then Exit;
      Row := aTable.rows.item(aRow, aRow) as IHTMLTableRow;
      if Row = nil then Exit;
      Result := Row as IHTMLElement;
    end;function GetWebBrowserHtmlTableHtml(const AWebBrowser: TWebBrowser;
      const TableIndex, RowIndex: Integer;
      var ResValue: string): Boolean;
    var
      Docintf: IHTMLDocument2;
      tblintf: IHTMLTable;
      node: IHTMLElement;
    begin
      ResValue := '';
      docintf := AWebBrowser.Document as IHTMLDocument2;
      tblintf := GetHtmlTable(docintf, TableIndex);
      node := GeHtmlTableHtml(tblintf, RowIndex);
      Result := node <> nil;
      if Result then
        ResValue := node.innerHtml;
    end;