Answer the question
In order to leave comments, you need to log in
How (and is it possible) to parse data through javascript?
I am writing a client application (an interactive map of the site) The customer asked me to indicate the weather in the area (available only on gismeteo), I had an idea to parse these values from there,
https://www.gismeteo.ru/city/daily/186725/
Previously wrote parsers in php, and here is a client application and for this I don’t want to use php, advise how you can do this using javascript, maybe there are special libraries?
Answer the question
In order to leave comments, you need to log in
What is parsing? This is a two-step process:
It would seem that there are no problems with the first step, because there is ajax. But there is a restriction on same-origin that you need to keep in mind.
The second step is also simple - build a DOM tree and look for what you want using standard methods. And if json is given, then beauty is at all.
But if you think about it, it's easy to shoot off the user's leg in this way - the request can hang, load the client's browser, etc. And the data changes once a day or even less often.
It’s more reasonable to write a separate parser script in this situation, which will run once a day by cron and write the values obtained somewhere. And clients will already pick them up from the server, either together with the page, or with a separate request.
It's a bad idea to parse gismeteo, since it is prohibited in the User Agreement
.
It's better to create a ready-made informer here https://www.gismeteo.ru/informers/ but again you need to read the terms of use, which may not be suitable https://www.gismeteo.ru/ informers/offer/
Such things.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question