httpclient is not downloading the whole html page body

Asked

Viewed 47 times

-1

When I try to get the page down "https://soundcloud.com/mecaaaa" she doesn’t lower the whole body of the body, so I can’t do what I’m aiming for.

Code I’m using to retrieve page data.

public string DownloadString(string URL)
    {
        using (HttpClient client = new HttpClient())
        {
            using (HttpResponseMessage response = client.GetAsync(URL).Result)
            {

                using (HttpContent content = response.Content)
                {
                    return content.ReadAsStringAsync().Result;
                }
            }
        }
    }

Does anyone know how to solve my problem? If necessary I can put the part that is being taken from the page

  • What is the purpose?

  • What are you trying to catch? Here loaded normally, have to see if what you want to load is in fact in the request you are using, the page does not bring everything monolithic, have to be observed the requests.

  • @Lucasmiranda I’m trying to get the link of the songs that are on the page, but these links do not appear in the html that the code receives

  • Glancing here to see that this data is coming from a request at this endpoint here: https://api-v2.soundcloud.com/stream/users/ you will need to take a look at how it sends the parameters and emulate

1 answer

0


Check if the links you are looking for are not loaded with JS, that is, after the page load. If this happens, you will not be able to get the HTML elements using Httpclient, as it does not process JS.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.