Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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("")
println (
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment