Donate

Login To Facebook Account Using C#, Webbrowser And LINQ

Hi,
Here's how to login to your facebook account using Webbrowser control and LINQ in Windows Forms. The input elements are checked through their attributes like "email" for email fields, "password" for password fields and "submit" for submission control. These codes are inside the DocumentCompleted event.
C# code
WebBrowser1.Document.GetElementsByTagName("input").Cast<HtmlElement>().FirstOrDefault(t => t.GetAttribute("type") == "email").SetAttribute("value", "your email address");
WebBrowser1.Document.GetElementsByTagName("input").Cast<HtmlElement>().FirstOrDefault(t => t.GetAttribute("type") == "password").SetAttribute("value", "your user name");
WebBrowser1.Document.GetElementsByTagName("input").Cast<HtmlElement>().FirstOrDefault(t => t.GetAttribute("type") == "submit").InvokeMember("click");       
VB.NET Code
WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(t) t.GetAttribute("type") = "email").SetAttribute("value", "your email address")
WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(t) t.GetAttribute("type") = "password").SetAttribute("value", "your user name")
WebBrowser1.Document.GetElementsByTagName("input").Cast(Of HtmlElement)().FirstOrDefault(Function(t) t.GetAttribute("type") = "submit").InvokeMember("click")

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.