Hello People
So after a long absence from bytebeats i am back in business . Here is my recent code that i have been working on from the last few days so thought of sharing it with you.
Currently this code is working for facebook but you can use this code for any website you want. If you want to login to facebook using vb.net then follow the following code.
Create a form application in vb.net
Drag a WebBrowser component to the form and paste the following code in the Class.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(“https://www.facebook.com/login.php”)
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
WebBrowser1.Document.GetElementById(“email”).SetAttribute(“value”, “email@email.com”)
WebBrowser1.Document.GetElementById(“pass”).SetAttribute(“value”, “password”)
WebBrowser1.Document.GetElementById(“login”).InvokeMember(“click”)
End Sub
End Class
Description
WebBrowser1.Navigate(“https://www.facebook.com/login.php”)
This line will navigate to the home page of facebook.
Then the event DocumentComplete will be fired and the following code will fill the username and password in the input fields. You can write all the code in the Load method but it will crash after the navigate because you have to wait for the document to load in the WebBrowser component.
WebBrowser1.Document.GetElementById(“email”).SetAttribute(“value”, “email@email.com”)
WebBrowser1.Document.GetElementById(“pass”).SetAttribute(“value”, “password”)
This code will click the log in to log in to facebook.
WebBrowser1.Document.GetElementById(“login”).InvokeMember(“click”)
Happy coding
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-29654614-1’]);
_gaq.push([‘_trackPageview’]);
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
January 9, 2012
2 Comments