mooman_fl Posted November 7, 2006 Posted November 7, 2006 I am working on an application that has a webbrowser control and a textbox. The particular page that the browser points to is a blog that has a submit form on it to post a reply to the particular thread. Replys are submitted via post, but the text editor on the page is sorely lacking in features. The application I am making needs to be able to take text from the custom editor in my application and submit it through the webbrowser via a POST command. IS there a way to accomplish this? Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
mooman_fl Posted November 8, 2006 Author Posted November 8, 2006 (edited) Did some research on this and found what I think I was looking for. Unfortunately I can't seem to get it to work. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim username As String = txtUsername.Text Dim password As String = txtPassword.Text Dim postdata As Byte() = System.Text.Encoding.ASCII.GetBytes("username=" + username + "&password=" + password) WebBrowser1.Navigate("http://www.drudge.com/log-in", "", postdata, "Content-Type:application/x-www-form-urlencoded" + [size=2]vbCrLf[/size]) End Sub P.S. - Sorry, I tried to use the VB tags instead of the CODE tags, but it kept screwing up the formatting and putting everything on one line. Edited November 8, 2006 by mooman_fl Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
mooman_fl Posted November 8, 2006 Author Posted November 8, 2006 If it helps, here is the relevant code from the webpage's login form: <form method="post" action="http://www.drudge.com/log-in"> Username: <input tabindex="2" id="username" name="username" value=""> Password: <input tabindex="3" id="password" name="password" type="password" value=""> <input type="submit" name="command" value="Log In"> </form> Any help on this would be greatly appreciated. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Leaders dynamic_sysop Posted November 9, 2006 Leaders Posted November 9, 2006 don't forget you need 2 X VbCrlf at the end of http data, if i remember it's also advised to add the Host property in the header & i know from experience that some sites won't allow anything to happen unless they have the correct refferer url, so you may want to specify that also. Quote
mooman_fl Posted November 9, 2006 Author Posted November 9, 2006 Thanks... I will try that and post the results. In absence of a working solution I had moved forward in the app by "hijacking" the form elements from the application. It works, but I could drasticly reduce the amount of code needed by being able to just compose a POST and Navigate the page. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Allen G Posted November 17, 2006 Posted November 17, 2006 Why not use the UploadString method of the WebClient class. It would be a little bit difficult to parse the values, but a bit of regEx or a simple parse function it'd be a good solution. Quote
mooman_fl Posted November 17, 2006 Author Posted November 17, 2006 Why not use the UploadString method of the WebClient class. It would be a little bit difficult to parse the values' date=' but a bit of regEx or a simple parse function it'd be a good solution.[/quote']Mainly because I am trying to work with the page already loaded in the browser control on the form. I have found an easy enough remedy that accomplishes what I want. I simply insert the values into the controls on the page then invoke the click event for the submit button. Doing it through the actual page bypasses possible problems with referrer and session data on the the server side. Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.