Created
May 26, 2013 11:55
-
-
Save kimukou/5652583 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//see http://jsoup.org/apidocs/ | |
// http://jsoup.org/cookbook/extracting-data/example-list-links | |
@Grab(group='org.jsoup', module='jsoup', version='1.7.2') | |
url ="http://atnd.org/events/39189" | |
//def txt = new URL(url).getText() | |
//println txt | |
import org.jsoup.Jsoup; | |
import org.jsoup.helper.Validate; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; | |
Document doc = Jsoup.connect(url).get() | |
//Elements title = document.getElementsByTag("title") | |
//println title | |
println "-----------------------------------------------------------" | |
//Elements links = doc.select("a[href]"); | |
Elements spans = doc.select("li span"); | |
for(Element span: spans){ | |
if(span.attr("class")=="red symbol"){ | |
} | |
else{ | |
//println span; | |
Element img = span.children()[0]; | |
//println img?.dump(); | |
img_url=img?.attr("src") | |
println "img_url:$img_url"; | |
//name=img?.attr("alt") | |
//println "name:$name"; | |
Element user = span.children()[1]; | |
//println user?.dump(); | |
println "name:"+user?.text(); | |
Element comment = span.children()[2]; | |
println "comment:"+comment?.text(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment