Popular Posts
Tomcat GET encoding edit server.xml : <Connector     URIEncoding="UTF-8"     connectionTimeout="20000"     port="8080"     prot... Activate IIS GIZP compress 1. Set metabase editable for editing. 2. Add a new extension for gzip. 3. Edit the file c:\windows\system32\inetsrv\MetaBase.xml Add file... Sublime Text hotkeys 編輯 Ctrl + X 刪除行 Ctrl + Enter 插入下一行 Ctrl + Shift + Enter 插入前一行 Ctrl + Shift + ↑ 往上移動一行 C...
Stats
Wrong text encoding while Jsoup parse document

While page encoding is different with content type encoding declaration. Jsoup will get wrong text decode content. To avoid this problem, Assign a correct text encoding will be required.

Connection connection = Jsoup.connect(requestUrl)
        .data("type", "1")
        .data("searchKeyUID", searchKeyUID)
        .timeout(timeout)
        .method(Connection.Method.GET);

Connection.Response response = connection.execute();
Document document = Jsoup.parse(new ByteArrayInputStream(response.bodyAsBytes()), "UTF-8", requestUrl);