Created
August 6, 2016 20:07
-
-
Save timyates/6dc59fc12124448cd3a47a1046028518 to your computer and use it in GitHub Desktop.
Download Public PBase Galleries with Groovy
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
@Grab('net.sourceforge.nekohtml:nekohtml:1.9.16') | |
def outFolder = new File("/folder/to/download/to") | |
outFolder.mkdirs() | |
def url = 'http://www.pbase.com/USERNAME/GALLERYNAME&page=all' | |
def parser = new org.cyberneko.html.parsers.SAXParser() | |
new XmlSlurper(parser).parse(url) | |
.'**' | |
.findAll { it.name() == 'A' && it.@class == 'thumbnail' }*.@href*.text() | |
.collect { page -> | |
new XmlSlurper(parser).parse(page).'**'.find { it.name() == 'IMG' && it.@class == 'display' }[email protected]() | |
} | |
.each { address -> | |
new File(outFolder, "${address.tokenize('/')[-1]}").withOutputStream { out -> | |
out << new URL(address).openStream() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to use this script but cannot get it to work.
I edited the outFolder and url in the script.
It created the outFolder but did not seem to download anything.
Could you give me instruction on how to use it? Thanks!