Answer the question
In order to leave comments, you need to log in
Is it possible to parse a page with Javascript and save its results?
Interested in the question of parsing an html page by setting up a script (or js code) so that the necessary elements (tables, lists) are parsed and saved to a separate file. Like regular php parsers, but in JS. Is it realistic to do it? How justified is this decision?
Answer the question
In order to leave comments, you need to log in
Walking through DOM elements and collecting data from them is easy. You can rotate all the elements of the page and their content as you please, otherwise why would js be needed at all.
Save to a file is unlikely, due to restrictions on sending requests via the file:// protocol . Be that as it may, the collected data, again, can be presented as you like in the format of a web page, which then, in extreme cases, you can save by hand. If you really want to automate everything simply and beautifully, then it is logical to look towards the same Groovy, Python and others like them.
1. On all points - the answer is: YES.
2. How justified? - depends on your goal.
It must be remembered that you can never trust client information.
If it is necessary for users of your service / site or users who send information to your server - trusted persons, then YES - this is justified. Otherwise - NO.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question