Skip to content

Instantly share code, notes, and snippets.

@mpen
Created November 22, 2009 08:21
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 mpen/240483 to your computer and use it in GitHub Desktop.
Save mpen/240483 to your computer and use it in GitHub Desktop.
TwitterのPublic Timelineを取得し、ユーザ名とツイートを表示する
// TwitterのPublic Timelineを取得し、ユーザ名とツイートを表示する
// 元 http://gist.github.com/240444
import scala.io.Source
import scala.xml.XML
val source = Source.fromURL("http://twitter.com/statuses/public_timeline.xml", "UTF-8")
val contents = source.getLines.mkString
val doc = XML.loadString(contents)
val tweets =
for (status <- doc \ "status")
yield ((status \ "user" \ "screen_name").text, (status \ "text").text)
for ((name, text) <- tweets)
println("@" + name + " : " + text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment