Skip to content

Instantly share code, notes, and snippets.

@zaltoprofen
Last active August 29, 2015 14:19
Show Gist options
  • Save zaltoprofen/0f5a5ea26b91ac08eb83 to your computer and use it in GitHub Desktop.
Save zaltoprofen/0f5a5ea26b91ac08eb83 to your computer and use it in GitHub Desktop.
enumerate the urls of 🍣 and 🍜 from twitter.
import twitter4j._
object Main{
def main(args: Array[String]): Unit = {
val t = new TwitterStreamFactory().getInstance
t.addListener(new UserStreamAdapter {
override def onStatus(status: Status): Unit = {
val urls = status.getMediaEntities().collect { case e:MediaEntity if e.getType == "photo" => e.getMediaURL }
val eurls = status.getExtendedMediaEntities().collect { case e:ExtendedMediaEntity if e.getType == "photo" => e.getMediaURL }
(urls ++ eurls).distinct.foreach(println)
}
})
val q = new FilterQuery().track(Array[String]("寿司", "ラーパン"))
t.filter(q)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment