从Htmltable检索数据 [英] Retrieve data from Htmltable

查看:111
本文介绍了从Htmltable检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用vb.net从html表的特定对象中检索数据?我在webbrowser控件中打开了一个包含该表的网页,现在我要检索该表的数据..并希望将该表的数据存储在数组中..该表首先包含数字,例如1单元格,第二个单元格中的2个.....以此类推,最多20个......它只有一行....

How to retrieve the data from particulre of html table using vb.net???????? I opened one webpage in webbrowser control which contains the table now i want to retrive the data of that table....and want to stored the data of that table in array.....that table contains numeric values like 1 in first cell,2 in second cell.....and so on up to 20......it has only one row....

推荐答案

第一个您需要获取页面的实际HTML,我从未使用过任何WebBrowser控件,所以我不知道它们是否通过提供属性来简化操作,而且我也不知道什么UI框架您正在使用,我不会花时间去查找它,但是我相信您可以自己弄清楚.

有了HTML之后,您就需要解析/抓取它,因此,如果只有一个表可以找到"<table"模式,那么您就必须寻找一种可以在HTML字符串中搜索的模式.在表格的开始处,您只需找到"<td"并获取">""</"之间的所有文本,然后重复该操作,直到您按下"</table>"
First you need to get the actual HTML of the page, I''ve never used any WebBrowser control so I don''t know if they make it easy by providing a property or not, and as I don''t know what UI framework you''re using I won''t spend time on looking it up, but I''m sure you can figure that out yourself.

Once you have the HTML you need to parse/scrape it, so you have to look for a pattern you can search for in the HTML-string if there is only one table that pattern could be "<table" once you''ve found the start of the table you just find the "<td" and take all text between ">" and "</" and you repeat that until you hit "</table>"


即可访问和操作使用 WebBrowser.Document [ HtmlDocument.GetElementById [
You can access and manipulate the page using the WebBrowser.Document[^] property. The HtmlDocument.GetElementById[^] would probably allow you to access the table more or less directly.

Best regards
Espen Harlinn


这篇关于从Htmltable检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆