首页 > 解决方案 > 意外状态行:

问题描述

我想获取并解析特定的网站:http : //trafo2.fesb.hr/index.html using Android & Kotlin Problem makes HTML 4.01(ISO 8879) where any technologies (Jsoup, okhttp. url.readText ... ) 给出相同的错误。

我尝试了我在互联网上找到的几乎所有东西以及我的数千个想法,但没有一个奏效。我尝试使用 Jsoup、Okhttp、URL ..

这只是几次不成功的尝试(一一尝试,抱歉混乱)......

         try {
        val url =URL( "http://trafo2.fesb.hr/index.html")
       /*val con =Jsoup.connect("http://trafo2.fesb.hr/index.html").followRedirects(true)
     val resp = con.execute().method(Connection.Method.GET)*/
 //  val completeFile = resp.body()
      //  val doc = resp.parse()


       // val doc = Jsoup.parse(URL("http://trafo2.fesb.hr/index.html"), 2000)
       // val doc  = Jsoup.connect("http://trafo2.fesb.hr/index.html").get()
        //val doc = Jsoup.parse(Jsoup.connect("http://trafo2.fesb.hr/index.html").ignoreHttpErrors(true).get().html())
       /* val urlConnection = url.openConnection() as HttpURLConnection
        val text = urlConnection.inputStream.bufferedReader().readText()*/

        val okHtttClient = OkHttpClient()
        val request = Request.Builder().url(url).build()

        val response = okHtttClient.newCall(request).execute()

如果有人试图访问上面写的 url,这将意味着很多,因为我仍然不知道为什么我会收到这个错误。提前致谢。

标签: androidhttpurljsoupokhttp

解决方案


推荐阅读