HTML網頁Table解析

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   ar   for   sp   div   

procedure TForm27.Button1Click(Sender: TObject);var  doc2: IHTMLDocument2;  doc3: IHTMLDocument3;  itableCollection, emtCollection: IHTMLElementCollection;  itable: IHTMLTABLE;  emt: IHTMLElement;  tabrow: IHTMLTableRow;  tabsec: IHTMLTableSection;  I, J, K: integer;  sid, s1, s2, s3, s4, s5, sText: string;begin  ListBox1.Clear;  WebBrowser1.Navigate(‘http://zx.caipiao.163.com/trend/11xuan5/?beginPeriod=14092901&endPeriod=14100875&selectDate=4‘);  while WebBrowser1.Busy do    Application.ProcessMessages;  doc2 := self.WebBrowser1.Document as IHTMLDocument2;  doc3 := WebBrowser1.Document as IHTMLDocument3;  itableCollection := doc2.all.tags(‘table‘) as IHTMLElementCollection;  for I := 0 to itableCollection.Length - 1 do  begin    itable := itableCollection.item(I, 0) as IHTMLTABLE;    emt := itable as IHTMLElement;    if emt.id = ‘chartsTable‘ then    begin      emt := itable.tBodies.item(1, 0) as IHTMLElement; // tbody cpdata      tabsec := emt as IHTMLTableSection;      tabsec.rows.Length;      for J := 0 to tabsec.rows.Length - 1 do      begin        tabrow := tabsec.rows.item(J, 0) as IHTMLTableRow;        if tabrow.cells.Length < 10 then          Continue;        sid := (tabrow.cells.item(0, 0) as IHTMLElement).innerText; // 14100718        s1 := (tabrow.cells.item(2, 0) as IHTMLElement).innerText; // 01        s2 := (tabrow.cells.item(3, 0) as IHTMLElement).innerText; // 02        s3 := (tabrow.cells.item(4, 0) as IHTMLElement).innerText; // 03        s4 := (tabrow.cells.item(5, 0) as IHTMLElement).innerText; // 04        s5 := (tabrow.cells.item(6, 0) as IHTMLElement).innerText; // 05        sText := Format(‘%s %s %s %s %s %s‘, [sid, s1, s2, s3, s4, s5]);        ListBox1.Items.Add(sText);      end;    end;  end;end;

 

HTML網頁Table解析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.