Created
April 18, 2011 22:21
-
-
Save bobylito/926365 to your computer and use it in GitHub Desktop.
A small script for phantom.js that gets your mangas that came out last month
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
/* | |
* Are my mangas out yet?? AMMOY?? | |
* a little script that could be croned to know if the mangas you follow are out. | |
*/ | |
// Website where to fetch infos | |
var urlMV = "http://www.mangaverse.net/html/planning/listesorties.htm"; | |
// The regexp to get the info | |
var reTitre = /- (.+) ([0-9]+) \(.+\)/; | |
// The titles you follow | |
var maListeTitre = ["PLUTO", "Berserk", "Bleach", "Naruto"]; | |
try { | |
if (phantom.state.length === 0 ) { | |
phantom.state = "test"; | |
phantom.open(urlMV); | |
} | |
else { | |
var arrayOfBody = document.body.innerText.split("\n"); | |
var titres = arrayOfBody. | |
filter(function(elt, idx, arr){ | |
return reTitre.test(elt); | |
}). | |
map(function(elt){ | |
var t = reTitre.exec(elt); | |
return {"title":t[1], "volume":t[2]}; | |
}). | |
filter(function(elt){ | |
//console.log(elt.title +" "+ (maListeTitre.indexOf(elt.title)!==-1)); | |
return maListeTitre.indexOf(elt.title)!==-1; | |
}); | |
titres.forEach(function(e){ | |
console.log(e.title + "-" +e.volume); | |
}); | |
phantom.exit(); | |
} | |
} | |
catch (err) { | |
console.log(err); | |
phantom.exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment