Created
January 6, 2013 17:02
-
-
Save lekevicius/4468634 to your computer and use it in GitHub Desktop.
Download all IconMonstr icons (previous website version; might need modification to work on new design).
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
loadPage = (url) -> | |
casper.open(url).then -> | |
pageIcons = @evaluate -> | |
links = [] | |
$('a.thumbnail_link').each -> links.push $(@).attr('href') | |
links | |
# console.log pageIcons | |
allIcons.push icon for icon in pageIcons | |
hasNextPage = @evaluate -> $('.navigation a.next').length | |
# console.log hasNextPage | |
if hasNextPage | |
nextPageURL = @evaluate -> $('.navigation a.next').attr('href') | |
console.log nextPageURL | |
loadPage nextPageURL | |
else | |
console.log allIcons | |
downloadIcons() | |
downloadIcon = (url) -> | |
console.log url | |
casper.then -> | |
casper.open(url).then -> | |
pngURL = @evaluate -> $('a.download_png').attr('href') | |
svgURL = @evaluate -> $('a.download_svg').attr('href') | |
fileName = url.substr 22, url.length - 28 | |
console.log fileName | |
console.log pngURL | |
console.log svgURL | |
casper.download(pngURL, fileName + '.png') | |
casper.download(svgURL, fileName + '.svg') | |
downloadIcons = -> | |
for icon in allIcons | |
downloadIcon icon | |
casper = require('casper').create | |
verbose: true | |
logLevel: "debug" | |
clientScripts: ["jquery.js"] | |
allIcons = [] | |
casper.start().then -> | |
loadPage 'http://iconmonstr.com/' | |
casper.run -> | |
@echo 'Completed' | |
@exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found this and rewrote it for my needs: https://gist.github.com/illmat/7355599
Thanks for pushing me into casperjs ;)