开发者

c# solution for screenscraping into a datatable?

i have an excel macro that i am converting to c#. currently i am manually going to an already opened IE window, copying everything from it (html table) and pasting into exc开发者_如何学编程el worksheet. then i am manipulating the data. this works very well because pasting an html table into excel works fine!

i am trying to do the same thing in c# WITHOUT excel. i need to:

  1. get data from IE window
  2. read it into a datatable (in a similar way that if i were copying and pasting html table into excel sheet)

do you know if this is easily possible to do?

the TITLE of the IE window will be the same all the time.


You could skip the IE window and just use one of the web classes (WebClient, HTTPWebRequest/HTTPWebResponse) to load up a object version of the page. That would give you access to all the HTML on a page. Then you could parse the HTML and pull out whatever information you needed. Once you have the information it's pretty easy to do whatever you want with it.

Try doing a search on HTML parsing or HTML Parser and you should get some nice information on that topic.

EDIT

As another option, if you really don't want to do parsing. You could always setup a form with a WebBrowser Control and then use it to load the page. The WebBrowser control has a Document property that gives you access to a lot of the information on a page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜