Web scraping: Difference between revisions
Content added Content deleted
No edit summary |
(Added Kotlin) |
||
Line 1,065: | Line 1,065: | ||
</body></html> |
</body></html> |
||
</lang> |
</lang> |
||
=={{header|Kotlin}}== |
|||
<lang scala>// version 1.1.3 |
|||
import java.net.URL |
|||
import java.io.InputStreamReader |
|||
import java.util.Scanner |
|||
fun main(args: Array<String>) { |
|||
val url = URL("http://tycho.usno.navy.mil/cgi-bin/timer.pl") |
|||
val isr = InputStreamReader(url.openStream()) |
|||
val sc = Scanner(isr) |
|||
while (sc.hasNextLine()) { |
|||
val line = sc.nextLine() |
|||
if ("UTC" in line) { |
|||
println(line.drop(4).take(17)) |
|||
break |
|||
} |
|||
} |
|||
sc.close() |
|||
}</lang> |
|||
{{out}} |
|||
Sample output: |
|||
<pre> |
|||
Aug. 20, 22:38:26 |
|||
</pre> |
|||
=={{header|Lasso}}== |
=={{header|Lasso}}== |