javascripthtmlhttprequesthtml-agility-pack

Simulate a Web Site's auto form fill


It can be hard to understand because of my english, but here's my question:

The website is using the responses from GET or POST requests to fill in form elements. I want to automate it in HTML Agility Pack. How do I convert the scripts the website uses to fill in inputs? A method or something else?

I've tried to fill every input manually but it's hard.

string respTrafik = _driver.GetData(adress, "", "").Result;
HtmlAgilityPack.HtmlDocument dc = new HtmlAgilityPack.HtmlDocument();
dc.LoadHtml(respTrafik);

_driver is one of my modified classes and the GetData method uses the httpwebrequest class. After this process, I need to fill a form in dc. Then I will post that form to a url.

In normal browsers, scripts automatically fill all the inputs. I need to find a way to get that algorithm and use it with HAP.


Solution

  • To simulate the auto form-fill functionality of a website in your application using HTML Agility Pack (HAP), you must handle the dynamic behavior that websites typically execute through JavaScript. Since HAP doesn't execute JavaScript, you will need to reverse-engineer how the form is populated and reproduce that logic in your code.

    This involves:

    1. Analyzing the Website's Behavior
    2. Manipulating the HTML
    3. Simulating Script Logic
    4. Posting the Data