search

Home  >  Q&A  >  body text

gb2312 - Android用okhttp抓取网页内容乱码如何解决?

Android平台用okhttp的get请求抓取网页全文,然后中文乱码,如何破?
页面编码 gb2312

PHP中文网PHP中文网2773 days ago654

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 15:38:19

    You can use jsoup to capture the page. As for the garbled code conversion encoding format, is it useless?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 15:38:19

    OkHttp post request encoding problem solution method
    In the callback method onResponse method
    byte[] b = response.body().bytes(); //Get the bytes of data
    String info = new String(b, "GB2312"); //Then convert it to gb2312

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 15:38:19

    This is also okhttp crawling data and grabbing garbled characters
    You can take a look
    http://www.qianlipp.com/124.html

    reply
    0
  • Cancelreply