首页 / DELPHI / Delphi 解析HTML
Delphi 解析HTML
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Delphi 解析HTML,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2175字,纯文字阅读大概需要4分钟。
内容图文
procedure TForm1.btnphClick(Sender: TObject); var Document: IHTMLDocument2; FTableCollection, tempCoc: IHTMLElementCollection; table: IHTMLTABLE; TableRow: IHTMLTableRow; elmt: IHTMLEleMent; I, J, K: integer; str: string ; begin Document := WebBrowser1.Document as IHTMLDocument2; FTableCollection := Document.all; FTableCollection.Length; // FTableCollection.item(1, 0); FTableCollection := Document.all.tags(‘table‘) as IHTMLElementCollection; for I := 0to FTableCollection.Length - 1dobegin table := FTableCollection.item(I, 0) as IHTMLTABLE; //题数 for J := 0to table.rows.Length - 1dobegin TableRow := (table.rows.item(J, 0) as IHTMLTableRow); //每道题信息 str := ‘‘; for K := 0to TableRow.cells.Length - 1dobegin elmt := TableRow.cells.item(K, 0) as IHTMLEleMent; str := str + elmt.innerText + #9; end; str := StringReplace(str, ‘‘#$D#$A‘‘, ‘‘, [rfReplaceAll]); Memo3.Lines.Add(str); Memo3.Lines.Add(‘------------------------------------------‘); end; end; end;
URL := ‘http://bbs.csdn.net/forums/Delphi‘;
WebBrowser1.Navigate(URL);
下面是一行tablerow的数据,可以分解出来,<td><td>之间是一个cell列。
如何解析第一列的href、class之间的3个数据呢,?、delphi7 滚动条颜色、VCL组件开发及应用
< tr > < td class ="title" > < strong class ="green" >?</strong><a href="/topics/390861446" target="_blank" title="delphi7 滚动条颜色">delphi7 滚动条颜色</a><span class="forum_link">[<span class="parent"><a href="/forums/Delphi">Delphi</a></span><a href="/forums/DelphiVCL">VCL组件开发及应用</a>]</span></td><td class="tc">20</td><td class="tc"><a href="http://my.csdn.net/u010745617" rel="nofollow" target="_blank">u010745617</a><br /><span class="time">08-15 16:25</span></td><td class="tc">1</td><td class="tc"><a href="http://my.csdn.net/NongCunGongLu" rel="nofollow" target="_blank">NongCunGongLu</a><br /><span class="time">08-17 13:41</span></td><td class="tc"><a href="/topics/390861446/close" target="_blank">管理</a></td></tr>
原文:http://www.cnblogs.com/cb168/p/3918237.html
内容总结
以上是互联网集市为您收集整理的Delphi 解析HTML全部内容,希望文章能够帮你解决Delphi 解析HTML所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。