Main Area and Open Discussion > General Software Discussion
web automation
Renegade:
is there any other option?
I want to create my own standalone programs that automate webpages and secure them with password so that the source won't be visible! and sell them!
as I can do with AutoHotKey for desktop automation programs!
-kalos (September 02, 2014, 07:39 AM)
--- End quote ---
I've done a lot of web automation in the past using Visual Studio. I don't know if that's an option for you. There are a few tricks that you need to know to get things smooth, but it does work.
-Renegade (September 02, 2014, 08:43 AM)
--- End quote ---
how do you get VS to "see" a radio button or a text form in a website?
-kalos (September 14, 2014, 07:27 AM)
--- End quote ---
Here's an example:
--- Code: C# ---// This is the basic method to use when a document loads. Expect problems and check StackExchange. private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e){ // Get a collection of all the kinds of elements that you want to look at. // In this case, we're looking for <input> tags. HtmlElementCollection collection = webBrowser1.Document.GetElementsByTagName("input"); // Run through the collection and look for a specific element. foreach (HtmlElement element in collection) { // Check the name of the element. if (element.Name == "user") { element.InnerText = "kalos"; } // Check if the element has a specific attribute. if (element.GetAttribute("type") == "password") { this.Text = "Found it!"; element.InnerText = "some password"; } }} // This shows clicking a sbumit button. private void button1_Click(object sender, EventArgs e){ // Get a collection of all the kinds of elements that you want to look at. // In this case, we're looking for <input> tags. HtmlElementCollection collection = webBrowser1.Document.GetElementsByTagName("input"); // Run through the collection and look for a specific element. foreach (HtmlElement element in collection) { // Check if the element has a specific attribute. if (element.GetAttribute("type") == "submit") { this.Text = "Found the submit button!"; // This is how you click. It is not always 100% reliable. element.InvokeMember("Click"); } }}
Here's the compiled version:
WebBrowserForKalos.zip (39.53 kB - downloaded 282 times.)
It should look like this:
I think that should be enough to get you started.
kalos:
thanks!
Navigation
[0] Message Index
[*] Previous page
Go to full version