I would like to make a vb .net application that auto logs into places and retrieves data from them. I have already succeeded in doing this by opening internet explorer programmably and tabbing to enter name and password. But this is messy, and needs to be well timed. I'm using VB .Net. Is there a way to interface with sites to auto login. Maybe I could inject a cookie, but then the browser could change. Any suggestions would be very helpful. Thanks
-
duplicate: http://stackoverflow.com/questions/975426/how-to-programmatically-log-in-to-a-website-to-screenscape – Mauricio Scheffer Nov 17 '09 at 21:01
-
Is this a testing thing or are you trying to create a mashup type site? – Chuck Conway Nov 17 '09 at 21:02
6 Answers
Well, it really depends on what authentication scheme the sites use. It is possible to pass a Credentials object with an HttpWebRequest which can be used to authenticate against sites that use basic authentication, windows authentication and similar. But I can't think of a reliable way that would work for any and all sites.
- 25,076
- 4
- 67
- 89
'In vb.net...add a webbrowser control. Then use
webbrowser1.navigate("www.gmail.com")
'Then in the webbrowsers document completed event paste something like this.
'where I wrote "123456" you will put the id of the html element for the username textbox.
'where I wrote "abcdef" you will put the id of the html element for the password textbox.
webbrowser1.Document.GetElementById("123456").InnerText = "yourusernamehere"
webbrowser1.Document.GetElementById("abcdef").InnerText = "yourpasswordhere"
webbrowser1.Document.DomDocument.forms(0).submit()
- 11
- 1
Is there a way to interface with sites to auto login.
Yes, there is. Well, its just a POST HttpRequest or OAuth token. You can always use direct POST requests with the required headers for any token auth. You can also test these command with cURL from the CLI.
~Without taking VB.net into account~, you can auto login to a website by using:
Autologin via Keypass - http://keepass.info/ or https://www.keepassx.org/
Keypass automatically opens the login URL of the website, fill the login form and submits it.
Select website from your list, then press CTRL+U & CTRL+V - and you are logged in.
- 39,862
- 13
- 113
- 141
And CasperJS and PhantomJS may be a way forward too. Using a headless browser you can identify steps in JavaScript you would like to perform at a Website. Useful for interaction through to scraping.
- 3,166
- 1
- 24
- 38