Home > Mobile >  HttpClient c#- how to get dynamic content data?
HttpClient c#- how to get dynamic content data?

Time:10-01

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?

CodePudding user response:

You are getting html without results because they are loading the data when the page loads. Open dev tools in your browser and check the network tab, there you'll see that they pull the data from:

https://www.futbin.com/22/getPlayerSales?resourceId=239085&platform=pc

That returns a list of all the prices with dates in json.

CodePudding user response:

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);
}
  • Related