views:

149

answers:

2

Hi,

I am programmer and share trader.

Before
I have written a day trading application. Until last week it was possible to fetch realtime quotes from http://aktien.boerse.de/aktien_startseite.php?view=2&order=name%20asc&liste=prime&page=0 . Every time the site was surfed the quotes had changed. The HTML contents could then be decoded with regular expressions (regex).

Problem
They have stopped this service by today. Now the quotes are not realtime when surfing on the page. The only way to get stock quotes now is to use pushed quotes "Push starten"-Button. However I do not know how to basically fetch them in C#. When I create a webbrowser element the only way which I know to get the push quotes out of it is to give the webbrowser element the focus send key ctrl+A and ctrl+C and insert the data some where for decoding. This is not desired since the control is moved away from the user and in case some other control is clicked during the process this may result in unexpected behaviour.

Question
So is there a proper way to decode push stock quotes in C#?

Thanks a lot in advance,
--eric

A: 

You can access the DOM directly through the web browser control - for example to click the button you can use the following (where the browser control is called _browser):

HtmlDocument doc = _browser.Document;
HtmlElement el;
el = doc.GetElementById(ButtonName);
el.InvokeMember("click");

You can then access the broser DOM at intervals (using _browser.Document) and parse using regular expressions the same way as you were previously. A neater way may be to use XPath to extract the table and individual stock quotes

Macros
A: 

Hey Macros,

could you possibly be so kind as to post some code for the DOM parsing?

Before fetching the HTML code via HTTP every time, I actually wanted to do as you described (parsing the DOM), however it was not possible to do so yet.

Thanks a lot in advance,
--eric

Eric