Can you please tell us how using JavaScript you can get the HTML code of any web site by reference? And then pass it to a variable or to a *.txt file?
1 answer
Obtaining any data from another server beyond the standard API is called "parsing", we can parse using a normal browser JS any web page or any web address in general, that is, we can completely completely configure the HTTP request from the browser using JS , and this is done using the XMLHttpRequest technology, it allows us to make absolutely any HTTP request using browser-based JS (you should not pay attention to XML at the beginning of the technology name, it does not play a key role there). Over this technology there are a million wrappers, like Ajax in jQuery , which simplify and so very simple work with this technology.
If you need to save something to a file, I advise you to look in the direction of the File API from browsers, or in the direction of NodeJS .
Example:
var perem; $.ajax({ url: "site.com", }).done(function(data) { preme = data; }); And then from this variable we can save to the file.
- Can I have a code sample? Thank you - Max.
- oneUpdated the answer, if you are satisfied, mark it as correct. - Evgeny Ivanov