K
K
Kirill2020-06-30 16:56:06
Parsing
Kirill, 2020-06-30 16:56:06

Why can't I get the page's source code?

Good afternoon.
I would like to know why this code is applicable to habr, yandex and many others, but does not want to work with asos, adidas

var url = "https://ya.ru/";
var HttpClient = new HttpClient();
var html = HttpClient.GetStringAsync(url);
Console.WriteLine(html.Result);

What should be applied or in which direction to dig?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Peter, 2020-06-30
@petermzg

Because on these sites the page is generated by javascript.
And in order to parse, you need to either analyze the site architecture and try to get exactly the data from the API (if any), or use browsers that can execute JS and get the page from them.

Z
Zakharov Alexander, 2020-07-01
@AlexZaharow

You can use cefsharp to inject into the page using c# and wait for all boot scripts to load and fire there. If anything, there is also cefsharp.offscreen (headless) if you want to run it as a service or in the console.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question