Last active
December 15, 2015 21:29
-
-
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
This file contains 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
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" |
This file contains 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
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