Skip to content

Instantly share code, notes, and snippets.

@qwert2603
Created January 26, 2018 01:54
Show Gist options
  • Save qwert2603/bd33887b85d7f273749b5d6b9f953285 to your computer and use it in GitHub Desktop.
Save qwert2603/bd33887b85d7f273749b5d6b9f953285 to your computer and use it in GitHub Desktop.
import okhttp3.OkHttpClient
import okhttp3.Request
fun main(args: Array<String>) {
val urls = listOf(
"http://cmit22.ru/",
"http://eljur.ru/elektronnyi-klassnyi-zhurnal",
"https://salesap.ru/crm_sistemy_chto_eto",
"http://prostoysoft.ru/College.htm",
"http://tallanto.com/ru/programma-dlya-ucheta-uchenikov",
"https://otmechalka.com/",
"http://holyhope.ru/scheduler/",
"https://salesap.ru/otraslevyie-crm/crm-uchebnykh-centrov"
)
val client = OkHttpClient()
val t1 = "<title>"
val t2 = "</title>"
urls.forEach {
val response = client.newCall(Request.Builder().url(it).build()).execute()
val title = response.body()!!.string().let {
it.substring(it.toLowerCase().indexOf(t1) + t1.length, it.toLowerCase().indexOf(t2))
}
println("$title [Электронный ресурс] / Элетрон. текст. дан. — режим доступа: $it. — Загл. с экрана.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment