K
K
Kirill2021-07-20 19:07:53
go
Kirill, 2021-07-20 19:07:53

How to wait for JS to load on a page?

There is a simple GET request as a result of which I get a "naked" DOM.

Essence of the question:
Is there a way to wait until the components are loaded from JS, and only then give me the final page (as if I were using a browser)?

I heard about web drivers, but it seems inconvenient to me to use, for example, Selenium for this.
If you tell me alternatives I will be very happy.

client := &http.Client{}
request, _ := http.NewRequest("GET", url)
response, _ := client.Do(request)
body, _ := ioutil.ReadAll(response.Body)
fmt.Println(string(body))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-07-20
@BPL

golang does not execute any code received from the request, for it it is a stupid slice of bytes, all processing falls on you. Therefore, either chromedriver using agouti or some exotic libraries like v8go
But it’s better to specify the question and write what task you are trying to solve, most likely you don’t need to interact with js at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question