SHARE
TWEET

Crawler With Scala

doxuanthang Aug 28th, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   * Created by thang_dx on 8/28/17.
  3.   */
  4.  
  5. import org.jsoup.Jsoup
  6. import org.jsoup.nodes.Element
  7.  
  8. object main {
  9.  
  10.     def getBlogByUrl(url: String) = {
  11.         val doc = Jsoup.connect(url).get()
  12.         val title = doc.select("h1.entry-title").first()
  13.         val author = doc.select("span.author.vcard").first()
  14.         val publishAt = doc.select("span.timestamp.updated").first()
  15.         val category = doc.select("span.postcateg").first()
  16.         println("Title: "+title.text)
  17.         println("Author: "+author.text)
  18.         println("Publish At: "+publishAt.text)
  19.         println("Category: "+category.text)
  20.     }
  21.  
  22.     def main(args: Array[String]) = {
  23.         getBlogByUrl("http://labs.septeni-technology.jp/react-js/thuc-hanh-reactjs-presentation-component-va-container/")
  24.     }
  25.  
  26. }
RAW Paste Data
Top