##This is the code for the blog.
Created
November 30, 2012 14:42
-
-
Save daiksy/4176173 to your computer and use it in GitHub Desktop.
hentaiAdventCode_2
This file contains hidden or 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
trait hentaiConverter { | |
implicit def stringToHentaiChecker(s: String) = HentaiChecker(s) | |
case class HentaiChecker(s: String) { | |
def hentaiPower: Int = { | |
import scala.io.Source | |
val contents = Source.fromURL("http://www.google.co.jp/search?q=変態+%s".format(s), "utf8").getLines.mkString | |
val searchCountPattern = "約? ?([0-9,]+) ?件".r | |
val numberPattern = "[0-9]+".r | |
val searchedCount = numberPattern.findFirstIn(searchCountPattern.findFirstIn(contents).getOrElse("0").replace(",", "")).getOrElse("0").toInt | |
searchedCount | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment