Skip to content

Instantly share code, notes, and snippets.

@rkitover
Last active December 15, 2015 21:29
Show Gist options
  • Save rkitover/5326058 to your computer and use it in GitHub Desktop.
Save rkitover/5326058 to your computer and use it in GitHub Desktop.
sbt project to print north korea's tweets using JSoup and Bing translate
name := "tweets"
version := "0.1"
scalaVersion := "2.11.4"
libraryDependencies += "org.jsoup" % "jsoup" % "1.7.2"
libraryDependencies += "com.memetix" % "microsoft-translator-java-api" % "0.6.2"
import scala.collection.JavaConversions._
import org.jsoup.Jsoup
import com.memetix.mst.language.Language
import com.memetix.mst.MicrosoftTranslatorAPI
import com.memetix.mst.translate.Translate
object Tweets {
def main(args: Array[String]) {
val doc = Jsoup.connect("https://twitter.com/uriminzok").get
println(doc.title)
MicrosoftTranslatorAPI.setClientId("caelum_nk_twitter")
MicrosoftTranslatorAPI.setClientSecret("lrebPC6ztD3civ7ZL/HzKpgud9fTYq36GFogJM8C6zI=")
for (tweet <- doc.select("p.js-tweet-text")) {
println("\n" + Translate.execute(tweet.text, Language.KOREAN, Language.ENGLISH))
Thread.sleep(500)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment