Last active
May 18, 2018 10:45
-
-
Save mahmut-gundogdu/9e5e565da47df60cc89582d840c88d27 to your computer and use it in GitHub Desktop.
"Bildiğim kadarıyla yemeksepetinde belirli bir restorandan sipariş vermek istediğimizde eğer restoranımız yoğunsa, müsaitlik durumunu ara ara kendimiz kontrol etmemiz gerekiyor, bunun için herhangi bir bildirim göndermiyorlar." Kaynak: https://forum.donanimhaber.com/yemeksepeti-restoran-yogunluk-kontrol-programi-phantomjs--132909481 sahibi: Dh v…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code Start | |
'use strict'; | |
var fs = require('fs'); | |
var content = fs.read('restoran.txt'); | |
//console.log('read data:', content); | |
var kontrol=false; | |
var page = require('webpage').create(); | |
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36'; | |
page.open(content, function(status) { | |
if (status === "success") { | |
console.log("Sayfa basariyla acildi !"); | |
} | |
}); | |
page.onLoadFinished = function(status) { | |
if (status === "success") { | |
kontrol=false; | |
var d = new Date(); | |
var n = d.getTime(); | |
console.log(d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()); | |
var aa = page.evaluate(function() { | |
return document.getElementsByClassName('ys-icons ys-icons-warningBig').length | |
}) | |
if (aa > 0) { | |
console.log('Restoran Yogun'); | |
setTimeout(function(){page.reload();}, 60000); | |
} else { | |
console.log('Restoran Musait!'); | |
setTimeout(function() { | |
phantom.exit(); | |
}, 1000); | |
} | |
} else { | |
console.log('Sayfa Yuklenirken Sorun Olustu, Tekrar Deneniyor...'); | |
kontrol=true; | |
setTimeout(function(){ if (kontrol===true){page.reload();}}, 60000); | |
} | |
}; | |
//Code END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment