Search code examples
c#gethttpresponsedotnet-httpclientdynamic-content

HttpClient c#- how to get dynamic content data?


For example, i need to get price values from https://www.futbin.com/22/sales/415/erling-haaland?platform=pc, that are located on the 'sales-inner' table. The problem is that HTTP Response returns results without loaded prices.

HttpResponseMessage response = await client.GetAsync("https://www.futbin.com/22/sales/415/?platform=pc");
response.EnsureSuccessStatusCode();
string responseString = await response.Content.ReadAsStringAsync();

How to get these data?


Solution

  • The URL you have mentioned in the question renders the view. To get the actual data you need to check the below URLs. Please note that I have got the below URLs from the debugger window but you can check docs if APIs are already provided.

    https://www.futbin.com/22/getPlayerSales?resourceId=239085&platform=pc https://www.futbin.com/getPlayerChart?type=live-sales&resourceId=239085&platform=pc

    public async Task Main()
    {
        HttpClient client = new HttpClient();
        HttpResponseMessage response = await client.GetAsync(@"https://www.futbin.com/22/getPlayerSales?resourceId=239085&platform=pc");
        response.EnsureSuccessStatusCode();
        string responseString = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseString);
    }