Edit webpage values and submit by button click?

.net c# html html-agility-pack



    <body class=" products show us">

    <header id="header"></header>
    <div id="wrap">
        <div id="container" style="opacity: 1;">
            <div class="sidebar"></div>
            <article itemtype="http://schema.org/Product" itemscope="itemscope">
                    <img id="img-main" src="test.jpg" itemprop="image" alt="test"></img>

        <div id="zoom-lens"></div>
        <div id="zoom-holder" style="background: url("test.jpg") no-repeat scroll 0px 0px transparent;" data-background-image="test.jpg"></div>

<div id="details" data-style-limited-with-count="0" data-style-limited="false">

    <h1 itemprop="name"></h1>
    <p class="style" itemprop="model">


    <p class="description" itemprop="description"></p>
    <ul class="styles "> // STEP 1: GENERATE LIST OF STYLES PER data-style-name and select the one that matches via adding "selected" to a class""!
            <a class="selected" data-style-name="White" data-style-id="10570" data-sold-out="false" data-images="{"detail_url":"..."..."}" href="..." data-no-tubolink="data-no-tubolink"></a>


    <a class="" data-style-name="Black" data-style-id="10571" data-sold-out="true" data-images="{"detail_url":"..."..."}" href="..." data-no-tubolink="data-no-tubolink"></a>


<p class="price" itemtype="http://schema.org/Offer" itemscope="itemscope" itemprop="offers"></p>

<div id="cart-controls">

    <div id="cart-controls"> // STEP 2 => OPEN THIS!
        <form id="cart-addf" class="add" method="post" data-remote="true" action="/shop/168934/add" accept-charset="UTF-8">

    <div style="margin:0;padding:0;display:inline"></div> // STEP 3: GENERATE LIST OF OPTIONS (UNKNOWN AMOUNT OF FIELDSETS) AND SELECT OPTION(S)!
        <select id="size" name="size">
            <option value="25134"></option>
            <option value="25135"></option>
            <option value="25136"></option>
        <select id="qty" name="qty">
            <option value="1"></option>
            <option value="2"></option>
            <option value="3"></option>
            <option value="4"></option>
            <option value="5"></option>
            <option value="6"></option>
            <option value="7"></option>
            <option value="8"></option>
        <a class="next" href="..."></a>
    <fieldset id="add-remove-buttons">
        <input class="button" type="submit" value="add to cart" name="commit"></input> // STEP 4: CLICK BUTTON!

                                    <a class="button continue" href="/shop"></a>
                    <script id="cart-controls-add" type="text/x-nano-tmpl"></script>
                    <script id="cart-controls-remove" type="text/x-nano-tmpl"></script>
                    <script id="cart-controls-sold-out" type="text/x-nano-tmpl"></script>
                    <script id="cart-controls-limited" type="text/x-nano-tmpl"></script>
        <footer id="nav" style="opacity: 1;"></footer>
        <script type="text/javascript"></script>
        <script type="text/javascript"></script>
        <script type="text/javascript"></script>



Above is the HTML code that I would like to access, modify values, & then submit data.

I am using c# net 4.0 and HTMLAGILITYPACK to achieve this.

I wrote inside the HTML above 4 total comments (4 things in total that is needed).

I was wondering if the goal of editing values is possible with HTMLAGILITYPACK and if it was possible to click a button on the webpage to submit the values that would be edited.

I found a few references regarding this matter but do not know how to put to proper use.

1: How to click a link element programmatially with HTMLElement?

2: Clicking button automatically using HtmlAgilityPack


 HtmlAgilityPack.HtmlDocument doc = null;
 doc = new HtmlAgilityPack.HtmlDocument();
 doc.LoadHtml(new WebClient().DownloadString("website above that contains that HTML"));

Popular Answer

Not quite sure what you want to accomplish, but I think this might be on the right track:

See this to change any attributes in JQuery http://api.jquery.com/attr/

See this to change/add things that'll happen when you click something https://api.jquery.com/click/

Needless to say, I don't think you need to make the button "click itself", what's the point of it then? :P But you can make it that if you click it, it does the first thing it should first, and then the second thing after that, within the JQuery click function you'll presumably make.

But like pasty said, I'd like you to elaborate a bit more, feel free to comment and ask if something is unclear in this post.

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why