import java.net.Socket
import java.net.URL
import java.time
import java.time.format
import java.time.ZoneId
import java.util.Scanner
import scala.collection.JavaConverters._

def get(rawUrl: String): List[String] = {
    val url = new URL(rawUrl)
    val port = if (url.getPort > -1) url.getPort else 80
    val sock = new Socket(url.getHost, port)
    sock.getOutputStream.write(
        s"GET /${url.getPath()} HTTP/1.0\n\n".getBytes("UTF-8")
    )
    new Scanner(sock.getInputStream).useDelimiter("\n").asScala.toList
}

def genUrl(n: Long) = {
    val date = java.time.ZonedDateTime
        .now(ZoneId.of("Europe/Berlin"))
        .plusDays(n)
        .format(java.time.format.DateTimeFormatter.ISO_LOCAL_DATE)
    s"http: