如何在数据库中复制网页tabel数据 [英] how to copy the web page tabel data in database
本文介绍了如何在数据库中复制网页tabel数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我有带有tabel格式数据的网页我如何使用c#.net windows应用程序将数据提取到数据库。请帮助我。
Dear all,
I have web pages with tabel formate data how i can extract the data to database using c#.net windows application. Please help me.
推荐答案
根据您的表结构使用ADO.NET保存数据,例如:行方式。
这些将有所帮助:
MSDN:ADO.NET [ ^ ]
MSDN:使用ADO.NET访问数据 [ ^ ]
使用C#读取,插入,更新和删除简单的ADO.NET数据库。 [ ^ ]
Save the data using ADO.NET as per your table structure, e.g: row wise.
These will help:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]
Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]
我建议你使用Html Agility Pack。
你可以在这里。
如何使用它的一些例子这里。
示例代码:
I recommend you the "Html Agility Pack".
You can found it in here.
Some example how to use it here.
Sample code:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(@"<html><body><p><table id=""foo""><tr><th>hello</th></tr><tr><td>world</td></tr></table></body></html>");
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("//table")) {
Console.WriteLine("Found: " + table.Id);
foreach (HtmlNode row in table.SelectNodes("tr")) {
Console.WriteLine("row");
foreach (HtmlNode cell in row.SelectNodes("th|td")) {
Console.WriteLine("cell: " + cell.InnerText);
}
}
}
这篇关于如何在数据库中复制网页tabel数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文