Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Downloader + Parser implementation
package com.czechscala.blank
import com.gargoylesoftware.htmlunit.WebClient
import com.gargoylesoftware.htmlunit.html.HtmlPage
object Speedometer extends App {
val downloader = new HttpDownloader("http://www.dsl.sk/speedmeter.php?id=speed_test")
println (downloader.download())
}
abstract class Downloader {
def download() : Option[String]
}
class HttpDownloader(uri: String) extends Downloader {
private val webclient: WebClient = new WebClient()
def download() : Option[String] = {
val page: HtmlPage = webclient.getPage(uri)
//val out = new PrintWriter( new FileWriter("""D:\output.html"""))
val result = page.asXml()
val regex = """(\d+\.\d+) Kbps""".r
val speed = regex.findFirstIn(result)
speed
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.