我尝试过用Java或Python保存整个页面,也尝试过selenium和wget。 最后,我选择了HtmlUnit,因为它可以通过使用save()轻松实现。你知道吗
我的页面被截断了,汉字显示为“?”。 有没有办法改变编码?或者有其他工具来保存整个页面?你知道吗
我的代码:
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();
}
结果是:
<?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???????????????????????????????????????????????????????????????????????????"/>
...
这是HtmlUnit当前版本(版本2.33)中的一个bug。已修复此问题;将在https://twitter.com/HtmlUnit上通知是否有新的快照生成可用。你知道吗
相关问题 更多 >
编程相关推荐