Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing data to webpage 1

Status
Not open for further replies.

Keneda88

Programmer
Oct 30, 2007
18
0
0
US
hi,
I am semi new to programming and have encountered a problem. I want to open a web page, then send lets say a username and password or an email and password to a webpage that I do not control. An example would be creating a program that opens ww.tek-tips.com (in internet explorer or firefox or on a form in my program). once the page is opened it will take a variables that i have created and enter them into the username and password boxes. (Optional: then click enter)
thank you
 
alright thanks for the reply.
I know how to open a webpage using
(using gmail as the website)
System.Diagnostics.Process.start(
After this it would enter a user name and password that I entered into a textbox in the program. There is no easy what to do that?
 
You can do this with vb.net. It is not too hard. I have posted replies to similar requests in this forum. Lookup webpage, webbrowser, scraping, etc.

Essentially, you put the webbrowser control on your form. Load whatever page is on there. Now if your website is windows authentication where that windows login pops up, you need to do a reg change so you can pass the credentials in the web url.

If the site is like tek-tips and has its own login boxes, then it is a matter of getting the id's of the boxes and you can control them interactively in your code. I have some sample code I will post, don't have time at the second. I will tomorrow though. But the thing you are trying to do is definitely possible. I do it for a variety of things.
 
It's funny...and they call me a "Technical User" on this forum. Don't see how I can get that changed.
 
Here was one of my posts:

arznrchrd (TechnicalUser) 28 Sep 07 11:34
Hey there, word of advice. Do not use sendkeys. Is not 100% reliable. If you just want to login a page, you can host the website in your app using the webbrowser control. Once vb.net is hosting the website, you can programtically do whatever you want to the website; click buttons, put data in fields, read data, submit, etc. If a windows login comes up, you can add a reg value to your registry that allows you to pass the username and password (encrypted in your app.config file) to the website to login. The user will not see the login windows popup. Judging from your message though, it looks as if the website just has its own login and password boxes. Thus, a lot easier. As follows:

Load website:
Webbrowsercontrol1.Navigate(New System.Uri("
Look at the source and find the elements that you need.
You are going to use htmlelement and invokemember to enter data on the website and click the submit button. This should get your started in the right direction.
 
Did you need anything else on this or was the above good?
 
i think you gave me enough to get started. Between school and work i dont have that much time but this weekend im going to try to finsih the program up. Ill let you know if get stuck.
thanks
 
I was able to get my program to open the page using webbrowser. However I am having a little trouble with the htmlelement and invokemember. i believe i have found the elements i want.

Here is a part of the html i believe this is the username element but am not sure
<input class="login_input" type="text" name="usrname" value="">

There are also one for the email that is the same execpt the name=uemail

here is what i believe to be the password element
<input class="login_input" type="password" name="peeword">

last but not least the login button
input class="login_input" type="submit" value="Login" style="width: 50px;"

thanks again for all your help man
 
As follows; you did not include the name of the search button, but you should be able to understand from the following:

Dim hElement As HtmlElement = Nothing
Dim hElement2 As HtmlElement = Nothing
Dim helement3 As HtmlElement = Nothing

hElement = Webmycontrol.Document.GetElementById("usrname")
helement3 = Webmycontrol.Document.GetElementById("peeword")

hElement.SetAttribute("value", "yourusername")
helement3.SetAttribute("value", "yourpassword")

hElement2 = Webmycontrol.Document.GetElementById("your search button name")
hElement2.InvokeMember("click")


Let me know how it works out.

~CIAO (i'm a technical user according to this forum...ha ha ha.)
 
i have most of it working i just cant find the name of the sumbit button. it only gives me the class, type, and value
 
I was able to figure out a way around using the invokemember but i need to be able to store cookies. Is there a way to make the vb program accept and store cookies?
 
its a php page that i am going to. it gives me an error saying "An unknown error has occurred. Please check to make sure cookies are enabled.
 
ya i got it to work so all is good. another question on the same project though. in order to browse through a page of objects the website uses javascript. is there a way to invoke that java script from my program.
ex.
javascript:GoToPage(2);
this gets you to the second page.
javascript:gotopage(3);
the third page and so on.
 
See post to your other question submitted. A good thing is to open a new question in the forum. Keep each question under one posting. If you have a new one, post as a separate question. Easier for people to follow then.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top