Noob
Noob

Reputation: 1

Activate button in DownloadString

By creating the webBrowser on the Form, I can activate the button via code and read new information. But trying to retrieve the information via DownloadString(url) which also works.

    string html = new WebClient().DownloadString(url);
    WebBrowser browser = new WebBrowser()
    {
       ScriptErrorsSuppressed = true,
       DocumentText = string.Empty
    };
    System.Windows.Forms.HtmlDocument doc = browser.Document.OpenNew(true);
    doc.Write(html);
    doc.InvokeScript("Submit");

The page has functions where each button refreshes with new information and the URL does not change. The first time I go to the page, the button looks like this

`
<button class="btn btn-result btn-primary" id="btn-tekinfo" data-page="page-tekinfo" data-name="tekinfo" onclick="if (!window.__cfRLUnblockHandlers) return false; gtag('event', 'Resultat Buttons', {'Click': 'Tek'});"><span class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"><span class="sr-only">...</span></span> Tek</button>
`

and the content that I look at looks like this.

`<tr>
<td class="text-uppercase font-weight-bold">Brand</td>
<td id="brand">Visual Studio</td>
</tr>`

when the button has been pressed and the page updated, it looks like this.

`<tr id="placeholder-tek_total" class="hide" style="display: table-row;">
<td class="text-uppercase" width="60%">Tek Total</td>
<td width="40%"><span id="tek_total">2019</span> v</td>
</tr>`

But how can I activate the button and fetch new information without using webBrowser physically?

`Another question. When using webBrowser on Form, errors appear with reference to this script: https://connect.facebook.net/en_US/fbevents.js

Is it normal? And can I use it?`

As a beginner, there is always a lot of trying and searching, but everything is a learning process that only gives new areas to try. Have become "smarter", but still a lot to learn, such as the terms to be able to search. Haven't got that experience and knowledge yet, so I hope you can help me.

Upvotes: 0

Views: 47

Answers (0)

Related Questions