1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import kotlinx.coroutines.* import io.ktor.client.HttpClient import io.ktor.client.request.get import io.ktor.client.features.json.JsonFeature import io.ktor.client.features.json.serializer.KotlinxSerializer import kotlinx.serialization.Serializable @Serializable data class ResponseData(val data: String) fun main() { runBlocking { val client = HttpClient { install(JsonFeature) { serializer = KotlinxSerializer() } } for (i in 1..100) { val url = "https://www.jesusninoc.com/$i/" launch { try { val response: ResponseData = client.get(url) println("Respuesta de $url: ${response.data}") } catch (e: Exception) { println("Error al realizar la solicitud GET a $url: ${e.message}") } } } } } |