0

Sorry for my English. I try to get HTML content from this page https://www.scoreboard.com/game/berankis-ricardas-king-kevin-2018/WC4oWAqE/#h2h;all. In result my code return HTML which doesn't have time to loading.

static string GetHtml(string site)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(site);
        HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

        using (StreamReader stream = new StreamReader(
            resp.GetResponseStream(), Encoding.UTF8))
        {
            return stream.ReadToEnd();
        }
    }

For example I want to get innerHTML from id="tab-match-head-2-head", because this block loads after few second, I can't get content from there. How can I wait while all content will be loaded and then GetResponse this? It's like a window.onload in js but from other site. I really have no idea how to do this, please help.

1 Answers1

0

If I get your question correctly, There is no need for headless browser.

Juts hit F12 in your browser and see the network activity

var url = "https://d.scoreboard.com/x/feed/d_hh_WC4oWAqE_en-usa_1"; //<===
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.Headers.Add("x-fsign","SW9D1eZo"); //<===
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

using (StreamReader stream = new StreamReader(
    resp.GetResponseStream(), Encoding.UTF8))
{
    return stream.ReadToEnd();
}
Eser
  • 12,346
  • 1
  • 22
  • 32