简体   繁体   中英

Take HTML ID from a website to fill information and press buttons in c# or vb.net

I want to code a program that will automatically press some buttons in a website and fill information in the text areas by taking the id of the html.

I would like to know any ways that i can accomplish that using vb.net or c# (if you know anything that will be easier please let me know). I basically want the program to have a built in Web Browsers and see what it is doing, if that is not possible or there is a way to do it many times faster with a console i would be glad to hear.

After searching in countless forums i found that i could do such a thing with phantom.js but to be honest i would prefer to do that with something i'm more familiar with.

I am not asking you to do that for me, just a simple link to where i can find the information is fine.

**Edit

I used AHK & vb.net to do this

In Windows forms you can embed a webbrowser control and programmatically manipulate the DOM content of the HTML document. You also have further control to manipulate the DOM by importing Microsoft.mshtml which extends the basic functionality of the html elements offered by the .Net framework.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        this.webBrowser1.Navigated += WebBrowser1_Navigated;
    }

    private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        var doc = webBrowser1.Document;
        doc.InvokeScript("alert('hello')");
        var forms =doc.GetElementsByTagName("form");

    }

    private void btnGo_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate(txtUrl.Text);

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM