Answer the question
In order to leave comments, you need to log in
How to implement this in Node.js?
There is a specific site. Let's say transport.surge.sh There, when you click on the "Example" button, a file is downloaded.
How can I write a Node.js script that every minute would go to this site through a SPECIFIC browser and download this file?
Which way to dig? What modules/frameworks/libraries to use? I just don't even know which way to go.
Answer the question
In order to leave comments, you need to log in
Node.js has integration with Phantom.js (which is a headless browser as you ask)
var phantom = require('phantom');
var sitepage = null;
var phInstance = null;
phantom.create()
.then(instance => {
phInstance = instance;
return instance.createPage();
})
.then(page => {
sitepage = page;
return page.open('https://stackoverflow.com/');
})
.then(status => {
console.log(status);
return sitepage.property('content');
})
.then(content => {
console.log(content);
sitepage.close();
phInstance.exit();
})
.catch(error => {
console.log(error);
phInstance.exit();
});
https://github.com/request/request#custom-http-headers
This is an example of custom header substitution in the request module.
Wrap the whole thing in setInterval and process saving to a file in callback like this:
https://nodejs.org/api/fs.html#fs_fs_writefile_fil...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question