Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://stackoverflow.com/questions/41043004/what-are-ways-to-play-a-sound-in-phantomjs-casperjs
- // https://phantomjs.org/api/child_process/
- // https://docs.bitfinex.com/reference#rest-public-ticker
- // phantomjs play_PhantomJS
- // https://pastebin.com/gW1xtBme
- var object= {viewportSize:{width:200,height:100},settings:{userAgent:'Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0',
- javascriptEnabled:true,
- loadImages:false
- }}, page = require('webpage').create(object);
- function play(){
- require("child_process").execFile("mplayer", ["/mnt4/56_gb/downloads2/Technoboy - Into Deep.oga"], null, function (err, stdout, stderr) {
- console.log("execFileSTDOUT:"+ JSON.stringify(stdout)+ "\nexecFileSTDERR:"+ JSON.stringify(stderr))
- }); setTimeout(phantom.exit,5000);}
- function get_json_data(obj){return obj.evaluate(function(){var data=JSON.parse(document.body.innerText); data=data[0][7]*=1; return data.toFixed(2);});}
- function check(){var data=get_json_data(page); if(data && data <= 4500 || data >= 7500){console.log("data: "+data+" playing"); play();} else{open_page(); /*console.log("data: "+data+" checking");*/} }
- function open_page(){page.open("https://api-pub.bitfinex.com/v2/tickers?symbols=tBTCUSD", function(){setTimeout(check,5000);});};
- open_page();
- console.log("PhantomJS is Running");
Add Comment
Please, Sign In to add comment