How can I select a text box that is available on a webpage so that my program can add data to the selected text box?
I am trying to setup a C# program that will auto login to a series of websites.
Example website:
Current Code:
private void login()
{
System.Net.HttpWebRequest whatCDReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://what.cd/login.php");
HTMLDocument htmlDoc = new HTMLDocumentClass();
htmlDoc = (HTMLDocument)webBrowser1.Document;
HTMLInputElement username = (HTMLInputElement)htmlDoc.all.item("p", 0);
username.value = "Test";
}
Look, what you want to do is send form requests to the server. Parse the webpage for text box form controls and submit the data in a format that the server can use (usually, the data handling is done within PHP on the server end).
Look in the webpage file for a reference to the Javascript function that performs the action itself (it should format the data and send it to the server). I’d recommend implementing that by translating it to your language of choice OR you could run the Javascript function directly through some 3rd party library (despite what you may think, I find that the first option is ultimately easier for small tasks like this).