Created
April 13, 2012 16:04
-
-
Save zhouji/2377961 to your computer and use it in GitHub Desktop.
A script for download books from motie
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
// A script for download books from motie | |
import java.util.regex.Pattern | |
content= "" | |
def getIndex(indexURL){ | |
(indexURL.toURL().text =~ /a href="(\/book\/[0-9]+_[0-9]+)" >第/ ).each{ a, b -> | |
getPage("http://www.motie.com/"+b) | |
} | |
} | |
def getPage(pageURL){ | |
Pattern regex; | |
regex = Pattern.compile('<div class="hidden">(.*)</div>.*<div class="body-bg">', Pattern.DOTALL); | |
(pageURL.toURL().text =~ regex).each{ a,b -> | |
content += b | |
} | |
} | |
getIndex('http://www.motie.com/book/6723/chapter') | |
f = new File("book.txt") | |
f.write(content) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment