how to render page phantom js every minute

how to render page phantom js every minute



I want to render a website page with phantom js, argar can render automatically every few minutes?



Here is my code:


var url = 'http://live.7msport.com';
var page = require ('webpage'). create ();
var fs = require ('fs');

page.open (url, function (status)
if (status! == 'success')
console.log ('Fail');
phantom.exit ();
else
window.setTimeout (function ()
fs.write ('index.php', page.content, 'w');
phantom.exit ();
, 2000);

);




1 Answer
1



Hope this will help:->



The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).



The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed.



The ID value returned by setInterval() is used as the parameter for the clearInterval() method.



1000 ms = 1 second.



Tip: To execute a function only once, after a specified number of milliseconds, use the setTimeout() method.




function myFunction()
setInterval(function() alert("Hello"); , 3000);


<!DOCTYPE html>
<html>
<body>

<p>Click the button to wait 3 seconds, then alert "Hello".</p>
<p>After clicking away the alert box, an new alert box will appear in 3 seconds. This goes on forever...</p>
<button onclick="myFunction()">Try it</button>
</body>
</html>




var url = 'http://live.7msport.com';
var page = require ('webpage'). create ();
var fs = require ('fs');
page.open (url, function (status) if (status! == 'success') console.log ('Fail'); phantom.exit ();
else
window.setInterval (function ()
fs.write ('index.php', page.content, 'w');
phantom.exit ();
, 60000);

);



setInterval takes 2 arguments
1.)Function
2.)interval to again render the page(in milliseconds)






Welcome to S.O. Including a brief description of how the code answers the question will help others with the same problem.

– Ageax
Sep 10 '18 at 3:25






this code is not work, I run in cmd

– exsan renaldhi
Sep 10 '18 at 3:27






@exsanrenaldhi now check the above example.

– Shivam Arora
Sep 10 '18 at 3:53






thanks for answer, i will try this

– exsan renaldhi
Sep 15 '18 at 3:05



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)