Navigate the web
-
I've been coding for quite sometime but never with web. I just need someone to help me get started. I'm trying to automatically push a button on a web page without a manual mouse click(its written in html). Where do I start? Can I even do it with C# or should I use another language. I was trying to use the standard webcontrol but it seems limited. Can anyone help? Thank you very much.
-
I've been coding for quite sometime but never with web. I just need someone to help me get started. I'm trying to automatically push a button on a web page without a manual mouse click(its written in html). Where do I start? Can I even do it with C# or should I use another language. I was trying to use the standard webcontrol but it seems limited. Can anyone help? Thank you very much.
Hi. It can be done quite easily with the webbrowser control. If this is what you would like to use I could guide you. Please reply if interested.
-
Hi. It can be done quite easily with the webbrowser control. If this is what you would like to use I could guide you. Please reply if interested.
-
Ok, here it is. I hope it's not too late. I was quite busy yesterday afternoon and I didn't have time to check the codeproject forum. So, a simple example of how to do an automatic search on google: Place a WebBrowser control on your form. Use it's navigate method to load the google page: MyWebBrowser.Navigate("http://www.google.com"); In order to access the controls on the webpage and use them, you need to know what their names are from the html source of the page. If you take a look at google's source you'll see all the controls, and among them these two: and The first one is the text box where you type the text to search and the second is the search button. So, all you need to do is fill the text box and after that simulate clicking the "Google Search" button. Like this: HtmlElement searchBox = MyWebBrowser.Document.All["q"]; searchBox.InnerText = "code project"; HtmlElement btnSearch = MyWebBrowser.Document.All["btnG"]; btnSearch.InvokeMember("click"); Hope this helps. Have a nice day! PS: There's a very quick and easy way to find the name of the controls you need from a web page. It's called Firebug. It's a plug-in for Firefox. Just use it. I'm sure you'll find it great, too.
-
Ok, here it is. I hope it's not too late. I was quite busy yesterday afternoon and I didn't have time to check the codeproject forum. So, a simple example of how to do an automatic search on google: Place a WebBrowser control on your form. Use it's navigate method to load the google page: MyWebBrowser.Navigate("http://www.google.com"); In order to access the controls on the webpage and use them, you need to know what their names are from the html source of the page. If you take a look at google's source you'll see all the controls, and among them these two: and The first one is the text box where you type the text to search and the second is the search button. So, all you need to do is fill the text box and after that simulate clicking the "Google Search" button. Like this: HtmlElement searchBox = MyWebBrowser.Document.All["q"]; searchBox.InnerText = "code project"; HtmlElement btnSearch = MyWebBrowser.Document.All["btnG"]; btnSearch.InvokeMember("click"); Hope this helps. Have a nice day! PS: There's a very quick and easy way to find the name of the controls you need from a web page. It's called Firebug. It's a plug-in for Firefox. Just use it. I'm sure you'll find it great, too.
-
Everything you said worked to perfection. Thanks for the help. Now that I have the basics down I am able to understand how the control works. You the man!
I'm glad I could help. Good luck and happy coding!
-
I'm glad I could help. Good luck and happy coding!
So how would you go about selecting certain boxes. Like username and password, and then click a button.
Login
Username:
Password:
-
So how would you go about selecting certain boxes. Like username and password, and then click a button.
Login
Username:
Password:
Well, I guess the same way I filled the search box on google's page. Have you tried setting the InnerText property? Maybe you could give me the link to the page you want to interact with and I'll try myself.
-
Well, I guess the same way I filled the search box on google's page. Have you tried setting the InnerText property? Maybe you could give me the link to the page you want to interact with and I'll try myself.
Alright I finnally got everything working except the button. To my knowledge i don't see the button in the source code. It just says
Did you get my email? -- modified at 2:20 Tuesday 29th May, 2007
-
Alright I finnally got everything working except the button. To my knowledge i don't see the button in the source code. It just says
Did you get my email? -- modified at 2:20 Tuesday 29th May, 2007
I didn't check my email yesterday. I'll read it in the afternoon(about 4-5 hours from now), as I'm not allowed to use my private email at work. Did you use Firebug to identify the web controls? If not, please do so. You'll see why.
-
I didn't check my email yesterday. I'll read it in the afternoon(about 4-5 hours from now), as I'm not allowed to use my private email at work. Did you use Firebug to identify the web controls? If not, please do so. You'll see why.
Well I actually took a look at another guys source and it pulls up the web page in the program itself. So I just had to modify it. The only problem is there is no button (in the web site) after you input the username and password. The site uses the php post method. Like www.site.net/login.php?user=Myusername&password=mypassword. But they have mypassword encrypted. So right now i'm trying to find away to either have the web browser click the button (but not seeing one in the source code) I think I will have to go with a way to manually click it.