Posting values to a web page

san monte

Member
Joined
Sep 8, 2005
Messages
17
Programming Experience
Beginner
Hello all
I am trying to post some data to a web page and submission but all with vb.net windows application No intraction with the web page.


If anybody know the answer please send your reply as quick as possible.

Thanks
Sandeep Sharma
 
What do you mean by: no interaction with the web page? You can try something like this:
VB.NET:
[COLOR=Blue]Dim [/COLOR]WebResp [COLOR=Blue]As[/COLOR] System.Net.HttpWebResponse
[COLOR=Blue]Dim [/COLOR]HTTPGetRequest As System.Net.HttpWebRequest
[COLOR=Blue]Dim [/COLOR]sr [COLOR=Blue]As[/COLOR] System.IO.StreamReader
[COLOR=Blue]Dim [/COLOR]myString [COLOR=Blue]As String[/COLOR]
[COLOR=Blue]Dim [/COLOR]SearchString [COLOR=Blue]As String[/COLOR]
SearchString = "help"
[COLOR=Blue]Dim [/COLOR]url [COLOR=Blue]As String[/COLOR] = "http://www.google.com/search?hl=en&q=" & SearchString
HTTPGetRequest = [COLOR=Blue]DirectCast[/COLOR](System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
HTTPGetRequest.KeepAlive = [COLOR=Blue]False[/COLOR]
WebResp = HTTPGetRequest.GetResponse()
sr = [COLOR=Blue]New [/COLOR]IO.StreamReader(WebResp.GetResponseStream(), System.Text.Encoding.ASCII)
myString = sr.ReadToEnd()
MessageBox.Show(myString)
 
Re defining the problem..

Sir ..
Thanks a lot for taking interest in my question..
And what u suggested is very fine in its kind.

But, the real thing i want to do is that--
Suppose there is a form on a web page..like an information form. You fill up some information in those fields and submit. For ex.
Your Name
Emai id
etc.
Then there is a button 'Submit'
You press the button and the data is Posted to the desired location.

The same thing i want to do with a VB application.
1. Load a URL.
2. Fill some fields of a particular form.
3. Submit these values.

At Last..i explain 'no interaction'
I just want to say that the process should be fully automated and performs all the three tasks in sequence and automatically. It will be more helpful if you can do that with a webbrowser control.
I think that would be clear sir.
Hoping a fast reply.
 
Re defining the problem..

ayozzhero said:
What do you mean by: no interaction with the web page? You can try something like this:
VB.NET:
[COLOR=blue]Dim [/COLOR]WebResp [COLOR=blue]As[/COLOR] System.Net.HttpWebResponse
[COLOR=blue]Dim [/COLOR]HTTPGetRequest As System.Net.HttpWebRequest
[COLOR=blue]Dim [/COLOR]sr [COLOR=blue]As[/COLOR] System.IO.StreamReader
[COLOR=blue]Dim [/COLOR]myString [COLOR=blue]As String[/COLOR]
[COLOR=blue]Dim [/COLOR]SearchString [COLOR=blue]As String[/COLOR]
SearchString = "help"
[COLOR=blue]Dim [/COLOR]url [COLOR=blue]As String[/COLOR] = "http://www.google.com/search?hl=en&q=" & SearchString
HTTPGetRequest = [COLOR=blue]DirectCast[/COLOR](System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
HTTPGetRequest.KeepAlive = [COLOR=blue]False[/COLOR]
WebResp = HTTPGetRequest.GetResponse()
sr = [COLOR=blue]New [/COLOR]IO.StreamReader(WebResp.GetResponseStream(), System.Text.Encoding.ASCII)
myString = sr.ReadToEnd()
MessageBox.Show(myString)


Sir ..
Thanks a lot for taking interest in my question..
And what u suggested is very fine in its kind.

But, the real thing i want to do is that--
Suppose there is a form on a web page..like an information form. You fill up some information in those fields and submit. For ex.
Your Name
Emai id
etc.
Then there is a button 'Submit'
You press the button and the data is Posted to the desired location.

The same thing i want to do with a VB application.
1. Load a URL.
2. Fill some fields of a particular form.
3. Submit these values.

At Last..i explain 'no interaction'
I just want to say that the process should be fully automated and performs all the three tasks in sequence and automatically. It will be more helpful if you can do that with a webbrowser control.
I think that would be clear sir.
Hoping a fast reply.
 
webbrowser control...? I think you're using .Net 2005 which I don't have. However, the concept of posting differs not from what I have posted. Because in Google, as in the example, commonly you have to open the page, type something in the query box and press submit.

Once you press submit, the browser posts the (almost) same command as url (as in the code). What you need to do, is to know how the script on the webpage works, e.g: what are the variables used. Let's say, the script accepts variable 'topic' as integer, the it looks like: http://www.yourdomain.com/script.ext?topic=1

That is how GET and POST works.

If you want to connect to the database directly without going through the script on the webserver, that is a different story where you have to consider many things. If you can post some codes, maybe we can work them out...
 
Basically Rakesh I think we are trying to say that we could do with some specifics to help us help you.

Where are you storing this data? MySQL, SQL Server etc ;-) hth
 
hey guys. i am a newbie to VB.net. i too have a problem similar to Rakesh. lemme see if i can explain it well enough :)
conditions: i have no control over the webpage. ( not hosted by me ) they might be forums, blogs etc the items will have names in the page, ie: text1 will be textbox1, submit is name of submit button etc

i have a program in VB6 that uses the webbrowser control to automate form submission. it can fill in text fields, select from drop-down / combo boxes / check boxes and also it can submit by clicking the submit button. the only thing it cant do is, it cant fill in the text field made by html code. so i was wondering whether VB.net is capable of doing it? if possible can u give me code example for each of the following?
  • fill a text field
  • set value for file field -- most imp
  • set value for drop-down / combo
  • set value for check box / options
  • submit the page by clicking the button.
thanks in advance ps: do i need more controls or will the webbrowser control be sufficient?
 
I agree with ayozzhero's above response. If you want no interaction then using the webbrowser control is overkill. The HttpWebResponse and other classes in the System.Net namespace is the way to go.
 
Back
Top