-1

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

1
  • Maybe there is API for such operations? Why you want to work with HTML? Commented Aug 21, 2024 at 7:57

2 Answers 2

1

This is what you're looking for:

mshtml.HTMLDocument htmlDoc = (mshtml.HTMLDocument)wb.Document.DomDocument;
var yourValue = htmlDoc.getElementById("[SomeID");
Sign up to request clarification or add additional context in comments.

1 Comment

I'm still getting the HTML source code of the page saying I don't have the permission ! It's weird.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.