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('org.jsoup:jsoup:1.7.1') | |
def url = "http://tw.user.bid.yahoo.com/tw/show/rating"; | |
def emptyList = ["?userID=Y6259654674&rate=seller&pg=1"]; | |
def result = []; | |
for (int i = 0; i < emptyList.size(); i++) { | |
def param = emptyList.get(i); | |
def doc = org.jsoup.Jsoup.connect(url + param).get() | |
println param; | |
// 擷取名稱 | |
doc.select(".aidpname a").each { | |
node-> | |
result.add(node.text()); | |
} | |
// 取得分頁資料 | |
doc.select(".pagination a").each { | |
node-> | |
if(!emptyList.contains(node.attr('href'))){ | |
emptyList.add(node.attr('href')); | |
} | |
} | |
} | |
// 列印 | |
result.sort().unique().each { | |
name-> | |
println name; | |
} |
http://blog.lyhdev.com/2012/12/groovy-jsoup-java-html-parser.html