java 数据抓取 serlvert 乱码问题
访问http://59.151.28.39/
public void captureJavascript(String queryTypeValue,String carMarkTValue,String VINNoValue) throws Exception {
String strURL = "http://59.151.28.39/servlet/SocietyUserQueryServlet?queryType="+queryTypeValue+"&carMarkT="+carMarkTValue+"&VINNo="+VINNoValue;
URL url = new URL(strURL);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
InputStreamReader input = new InputStreamReader(httpConn
.getInputStream(), "gbk");
BufferedReader bufReader = new BufferedReader(input);
String line = "";
StringBuilder contentBuf = new StringBuilder();
while ((line = bufReader.readLine()) != null) {
contentBuf.append(line);
}
System.out.println(strURL);
System.out.println("captureJavascript()的结果:\n" + contentBuf.toString());
}
demo.captureJavascript("thirdQueryMode", "京YZ1010", "LHGCP168882020305");
中文传递解析乱码,返回数据都是空,
求大神帮忙
[解决办法]
应该是他 后台有处理了 你直接浏览器敲过去,所以你模拟请求会得到以下的结果。
http://59.151.28.39/servlet/SocietyUserQueryServlet?queryType=thirdQueryMode&carMarkT=%E4%BA%ACYZ1010&VINNo=LHGCP168882020305
号牌号码:???YZ1010 , 车架号:LHGCP168882020305 的理赔信息:
交强险理赔信息
未查询到交强险理赔信息!
商业险理赔信息
未查询到商业险理赔信息!
<table border='0' width='100%' align='center' cellpadding='0' cellspacing='0'><tr class='table_td_condition'><td> <span class='table_td_condition1'>号牌号码:京YZ1010</span> , <span class='table_td_condition1'>车架号:LHGCP168882020305</span> 的理赔信息:</td></tr><tr><td><table border='0' width='99%' align='center' cellpadding='0' cellspacing='0'><tr><td class='rightDowenTitleCss' colspan='11'> 交强险理赔信息</td></tr><tr height='10px'><td></td></tr><tr height='50' class='queryOperationInf'><td>未查询到交强险理赔信息!</td></tr></table></td></tr><tr height='15'><td></td></tr><tr><td><table border='0' width='99%' align='center' cellpadding='0' cellspacing='0'><tr><td class='rightDowenTitleCss' colspan='11'> 商业险理赔信息</td></tr><tr height='30' class='thCss'><th>公司名称</th><th>号牌号码</th><th>号牌种类</th><th>出险时间</th><th>出险地点</th><th>报案时间</th><th>立案时间</th><th>结案时间</th><th>案件状态</th><th>赔款金额</th><th>联系电话</th></tr><tr class='tdCss'><td>人保</td><td>京YZ1010</td><td>小型汽车号牌</td><td>2013-06-02</td><td>房山区良乡</td><td>2013-06-02</td><td>2013-06-03</td><td>2013-06-13</td><td>已结案</td><td align='right'>1615.00</td><td> 58195470</td></tr></table></td></tr><tr height='15'><td></td></tr></table>
public static void captureJavascript(String queryTypeValue, String carMarkTValue,
String VINNoValue) throws Exception {
String strURL = "http://59.151.28.39/servlet/SocietyUserQueryServlet";
URL url = new URL(strURL);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setDoOutput(true);
httpConn.setRequestMethod("POST");
httpConn.connect();
OutputStream out = httpConn.getOutputStream();
String param= "queryType="
+ "thirdQueryMode"
+ "&carMarkT="
+ "京YZ1010"
+ "&VINNo="
+ "LHGCP168882020305";
out.write(param.getBytes());
out.flush();
out.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(httpConn
.getInputStream(),"GBK"));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
reader.close();
httpConn.disconnect();
System.out.println(buffer.toString());
}
//<table border='0' width='100%' align='center' cellpadding='0' cellspacing='0'><tr class='table_td_condition'><td> <span class='table_td_condition1'>号牌号码:京YZ1010</span> , <span class='table_td_condition1'>车架号:LHGCP168882020305</span> 的理赔信息:</td></tr><tr><td><table border='0' width='99%' align='center' cellpadding='0' cellspacing='0'><tr><td class='rightDowenTitleCss' colspan='11'> 交强险理赔信息</td></tr><tr height='10px'><td></td></tr><tr height='50' class='queryOperationInf'><td>未查询到交强险理赔信息!</td></tr></table></td></tr><tr height='15'><td></td></tr><tr><td><table border='0' width='99%' align='center' cellpadding='0' cellspacing='0'><tr><td class='rightDowenTitleCss' colspan='11'> 商业险理赔信息</td></tr><tr height='30' class='thCss'><th>公司名称</th><th>号牌号码</th><th>号牌种类</th><th>出险时间</th><th>出险地点</th><th>报案时间</th><th>立案时间</th><th>结案时间</th><th>案件状态</th><th>赔款金额</th><th>联系电话</th></tr><tr class='tdCss'><td>人保</td><td>京YZ1010</td><td>小型汽车号牌</td><td>2013-06-02</td><td>房山区良乡</td><td>2013-06-02</td><td>2013-06-03</td><td>2013-06-13</td><td>已结案</td><td align='right'>1615.00</td><td> 58195470</td></tr></table></td></tr><tr height='15'><td></td></tr></table>