Skip to content

Instantly share code, notes, and snippets.

@timyates
Created August 6, 2016 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timyates/6dc59fc12124448cd3a47a1046028518 to your computer and use it in GitHub Desktop.
Save timyates/6dc59fc12124448cd3a47a1046028518 to your computer and use it in GitHub Desktop.
Download Public PBase Galleries with Groovy
@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' }.@src.text()
}
.each { address ->
new File(outFolder, "${address.tokenize('/')[-1]}").withOutputStream { out ->
out << new URL(address).openStream()
}
}
@yopology
Copy link

yopology commented May 2, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment