Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A <em>hacky</em> approach would be to:</p> <ol> <li>Attach an event handler to the 'onclick' event of the button.</li> <li>Then, once the event is triggered, use the <em>Microsoft Internet Controls (SHDocVw)</em> type library in order to get the last URL opened in IE.</li> <li>Lastly, navigate to the URL and once the document is loaded, get the source of the document from the <code>webBrowser1.DocumentText</code> property.</li> </ol> <p>In your project, add a reference to the <em>Microsoft Internet Controls</em> type library (you'll find it in the <em>COM</em> tab). Add at the top of your file:</p> <pre><code>using SHDocVw; </code></pre> <p>The code:</p> <pre><code>webBrowser1.Navigate(url); while (webBrowser1.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } // assign the button to a variable var button = webBrowser1.Document.GetElementById("downloadButton"); // attach an event handler for the 'onclick' event of the button button.AttachEventHandler("onclick", (a, b) =&gt; { // use the Microsoft Internet Controls COM library var shellWindows = new SHDocVw.ShellWindows(); // get the location of the last window in the collection var newLocation = shellWindows.Cast&lt;SHDocVw.InternetExplorer&gt;() .Last().LocationURL; // navigate to the newLocation webBrowser1.Navigate(newLocation); while (webBrowser1.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } // get the document's source var source = webBrowser1.DocumentText; }); button.InvokeMember("click"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload