Reputation: 583
I'm building an application in C# to retrieve information from my bank account. So far, I'm able to connect to my bank account on https://accesd.desjardins.com. I first enter my card number and than my password on another page. Like this :
private void newweb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
switch (iStages)
{
case 1:
newweb.Document.GetElementById("card_num").SetAttribute("value", strCardNum);
newweb.Document.GetElementById("ch_but_logon").InvokeMember("click");
iStages = 2;
break;
case 2:
newweb.Document.GetElementById("passwd").SetAttribute("value", psswd);
newweb.Document.GetElementById("ch_but_logon").InvokeMember("click");
iStages = 3;
break;
}
}
But once I'm on my bank account page, I can't no longer use newweb.Document.GetElementById(..) to retrieve any html tags or elements. I want to get my total amount of money. But when I try to get any elements of the page, I always get a null element. When I tried to get the html source code of the page on Chrome, I got a html source code of a page saying that I do not have the permission to see the source code of the page (which is the one with my bank account). I was wondering how to get the source code by any means with C#. There is certainly a way of doing it, since the browser can show the web page. It must have read the source code in order to display it...
Thanks
Upvotes: -1
Views: 1313
Reputation: 12803
I've run into something similar before. You need to make sure that you are sending the cookies back with each web request. Banks store cookies that serve as flags that you're logged in. In addition, the connection is using SSL, so make sure that you've taken that into account in your code as well.
Upvotes: 1
Reputation: 61793
This is what you're looking for:
mshtml.HTMLDocument htmlDoc = (mshtml.HTMLDocument)wb.Document.DomDocument;
var yourValue = htmlDoc.getElementById("[SomeID");
Upvotes: 1