Truncated text when using HtmlUnit to save complete page












2















I've tried to save the complete page using Java or Python and I also have tried selenium and wget.
Finally I've chosen HtmlUnit because it can be easily achieved by using save().



My page is getting truncated, the Chinese characters show as "?".
Is there any way to change the encoding? Or there have any other tools to save the complete page?



My code:



    WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);

try {
HtmlPage htmlPage = webClient.getPage("http://www.fulijr.com/");
File file = new File("fulijr.html");
htmlPage.save(file);
} catch (IOException e) {
e.printStackTrace();
}


The result:



<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<meta name="keywords" content="????,????????,??????P2P????"/>
<meta name="description" content="??????????P2P???????????????????????????????????????????????????????????????????????????????????P2P???????????????????????????????????????????????????????????????????????????"/>
...









share|improve this question

























  • You have to do something like this (like in Fetch class): stackoverflow.com/a/44493023/4392611 and before saving read encoding declaration, otherwise it makes no sense.

    – Zydnar
    Nov 23 '18 at 14:03
















2















I've tried to save the complete page using Java or Python and I also have tried selenium and wget.
Finally I've chosen HtmlUnit because it can be easily achieved by using save().



My page is getting truncated, the Chinese characters show as "?".
Is there any way to change the encoding? Or there have any other tools to save the complete page?



My code:



    WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);

try {
HtmlPage htmlPage = webClient.getPage("http://www.fulijr.com/");
File file = new File("fulijr.html");
htmlPage.save(file);
} catch (IOException e) {
e.printStackTrace();
}


The result:



<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<meta name="keywords" content="????,????????,??????P2P????"/>
<meta name="description" content="??????????P2P???????????????????????????????????????????????????????????????????????????????????P2P???????????????????????????????????????????????????????????????????????????"/>
...









share|improve this question

























  • You have to do something like this (like in Fetch class): stackoverflow.com/a/44493023/4392611 and before saving read encoding declaration, otherwise it makes no sense.

    – Zydnar
    Nov 23 '18 at 14:03














2












2








2








I've tried to save the complete page using Java or Python and I also have tried selenium and wget.
Finally I've chosen HtmlUnit because it can be easily achieved by using save().



My page is getting truncated, the Chinese characters show as "?".
Is there any way to change the encoding? Or there have any other tools to save the complete page?



My code:



    WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);

try {
HtmlPage htmlPage = webClient.getPage("http://www.fulijr.com/");
File file = new File("fulijr.html");
htmlPage.save(file);
} catch (IOException e) {
e.printStackTrace();
}


The result:



<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<meta name="keywords" content="????,????????,??????P2P????"/>
<meta name="description" content="??????????P2P???????????????????????????????????????????????????????????????????????????????????P2P???????????????????????????????????????????????????????????????????????????"/>
...









share|improve this question
















I've tried to save the complete page using Java or Python and I also have tried selenium and wget.
Finally I've chosen HtmlUnit because it can be easily achieved by using save().



My page is getting truncated, the Chinese characters show as "?".
Is there any way to change the encoding? Or there have any other tools to save the complete page?



My code:



    WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);

try {
HtmlPage htmlPage = webClient.getPage("http://www.fulijr.com/");
File file = new File("fulijr.html");
htmlPage.save(file);
} catch (IOException e) {
e.printStackTrace();
}


The result:



<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<meta name="keywords" content="????,????????,??????P2P????"/>
<meta name="description" content="??????????P2P???????????????????????????????????????????????????????????????????????????????????P2P???????????????????????????????????????????????????????????????????????????"/>
...






java python web-crawler






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 11:30







user6490459

















asked Nov 23 '18 at 10:13









C.shayvC.shayv

162




162













  • You have to do something like this (like in Fetch class): stackoverflow.com/a/44493023/4392611 and before saving read encoding declaration, otherwise it makes no sense.

    – Zydnar
    Nov 23 '18 at 14:03



















  • You have to do something like this (like in Fetch class): stackoverflow.com/a/44493023/4392611 and before saving read encoding declaration, otherwise it makes no sense.

    – Zydnar
    Nov 23 '18 at 14:03

















You have to do something like this (like in Fetch class): stackoverflow.com/a/44493023/4392611 and before saving read encoding declaration, otherwise it makes no sense.

– Zydnar
Nov 23 '18 at 14:03





You have to do something like this (like in Fetch class): stackoverflow.com/a/44493023/4392611 and before saving read encoding declaration, otherwise it makes no sense.

– Zydnar
Nov 23 '18 at 14:03












1 Answer
1






active

oldest

votes


















1














This is a bug in the current version of HtmlUnit (version 2.33). Have fixed this; will inform on https://twitter.com/HtmlUnit if a new snapshot build is available.






share|improve this answer
























  • Thanks, I have tried build 2.34-SNAPSHOT and it's work.

    – C.shayv
    Nov 26 '18 at 1:18













  • When is the release for this 2.34 coming out?

    – Sulaiman Adeeyo
    Jan 16 at 14:55












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444689%2ftruncated-text-when-using-htmlunit-to-save-complete-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














This is a bug in the current version of HtmlUnit (version 2.33). Have fixed this; will inform on https://twitter.com/HtmlUnit if a new snapshot build is available.






share|improve this answer
























  • Thanks, I have tried build 2.34-SNAPSHOT and it's work.

    – C.shayv
    Nov 26 '18 at 1:18













  • When is the release for this 2.34 coming out?

    – Sulaiman Adeeyo
    Jan 16 at 14:55
















1














This is a bug in the current version of HtmlUnit (version 2.33). Have fixed this; will inform on https://twitter.com/HtmlUnit if a new snapshot build is available.






share|improve this answer
























  • Thanks, I have tried build 2.34-SNAPSHOT and it's work.

    – C.shayv
    Nov 26 '18 at 1:18













  • When is the release for this 2.34 coming out?

    – Sulaiman Adeeyo
    Jan 16 at 14:55














1












1








1







This is a bug in the current version of HtmlUnit (version 2.33). Have fixed this; will inform on https://twitter.com/HtmlUnit if a new snapshot build is available.






share|improve this answer













This is a bug in the current version of HtmlUnit (version 2.33). Have fixed this; will inform on https://twitter.com/HtmlUnit if a new snapshot build is available.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 20:09









RBRiRBRi

1,3662610




1,3662610













  • Thanks, I have tried build 2.34-SNAPSHOT and it's work.

    – C.shayv
    Nov 26 '18 at 1:18













  • When is the release for this 2.34 coming out?

    – Sulaiman Adeeyo
    Jan 16 at 14:55



















  • Thanks, I have tried build 2.34-SNAPSHOT and it's work.

    – C.shayv
    Nov 26 '18 at 1:18













  • When is the release for this 2.34 coming out?

    – Sulaiman Adeeyo
    Jan 16 at 14:55

















Thanks, I have tried build 2.34-SNAPSHOT and it's work.

– C.shayv
Nov 26 '18 at 1:18







Thanks, I have tried build 2.34-SNAPSHOT and it's work.

– C.shayv
Nov 26 '18 at 1:18















When is the release for this 2.34 coming out?

– Sulaiman Adeeyo
Jan 16 at 14:55





When is the release for this 2.34 coming out?

– Sulaiman Adeeyo
Jan 16 at 14:55




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444689%2ftruncated-text-when-using-htmlunit-to-save-complete-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini