Poser une questionPoser une question
 

TraitéeHow to login without webbrowser

  • mercredi 4 novembre 2009 20:30yterbium Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     A du code
    Hi everyone,

    I am trying to log in one site (with valid login and password) but I dont want to use webbrowser control in my app. this would work nice with webbrowser:
    void PrihlasPoNacitani(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                HtmlElementCollection elements = webBrowser1.Document.GetElementsByTagName("input");
                foreach (HtmlElement element in elements)
                {
                    if (element.Name == "username")
                    {
                        element.SetAttribute("value", meno);
                    }
                    if (element.Name == "password")
                    {
                        element.SetAttribute("value", heslo);
                    }
                    if (element.Name == "login")
                    {
                        element.InvokeMember("click");
    
                    }
                }
            }
    

    So is there any way how to do this without webbrowser. I can get automatically the source code of web page , but how to put and send my password and login into "input" type?

    thanks for answers

Réponses

  • jeudi 5 novembre 2009 08:53yterbium Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    sorry, I have formed it wrong...


    But what I wanted was that the webBrowser should not be in my app.

    So I figure it out, that I do not insert webbrowser into [design] view, but just do an instance in code like webBrowser web = new webBrowser()...

    It was late nigh yesterday, that was the problem probably.

    Sorry to bother you :-)

Toutes les réponses