意外的状态行:

时间:2019-05-06 10:34:05

标签: android http url jsoup okhttp

我想使用Android和Kotlin提取并解析特定的网站:http://trafo2.fesb.hr/index.html 问题使得HTML 4.01(ISO 8879)的任何技术(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,这将有很多意义,因为我仍然不知道为什么会出现此错误。 预先感谢。

0 个答案:

没有答案
相关问题