如何获取提交页面源码
我写的一个查询html源码的源码,不过没有查询到目标地址的源码
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.MalformedURLException;import java.net.URL;/** * @author happy * */public class JavaGetResource { public static void main(String[] args) { String uri = "http://jtk.sptcc.com:8080/servlet?addr=110.120.130.99&hiddentype=index&Card_id=72494857632"; String resource = getOneHtml(uri); System.out.println(resource); } public static String getOneHtml(String htmlurl) { URL url; String temp; StringBuffer sb = new StringBuffer(); try { url = new URL(htmlurl); BufferedReader in = new BufferedReader(new InputStreamReader(url .openStream(), "gbk")); // UTF-8 while ((temp = in.readLine()) != null) { sb.append(temp + "\n"); } in.close(); } catch (MalformedURLException me) { System.out.println("你输入的URL格式有问题!请仔细输入"); me.getMessage(); try { throw me; } catch (MalformedURLException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); try { throw e; } catch (IOException e1) { e1.printStackTrace(); } } return sb.toString(); }}
<html><head><link rel="stylesheet" type="text/css" href="images/jtk.css"><!--description:jtk_querytime:2005.8-2005-12author:zhu tian wei,zhang jun,yang juncompany:sinocomm ltd.--><title>jtk 上海市公共交通卡网上查询</title><meta http-equiv="Content-Type" content="text/html;"><script type="">function Ret_new(){//location.href("newMember.jsp");}function Ret_Vip(){//location.href("Vip_index.jsp");}function Checkout(){if (Form1.Card_id.value.length=='11') { if(Form1.User_name.value==""&&Form1.Pass_word.value=="") { return true; } else{ if(Form1.Pass_word.value!="") { alert("请输入用户名"); Form1.User_name.focus(); return false; } else if(Form1.User_name.value!="") { alert("请输入密码"); Form1.Pass_word.focus(); return false; } if(Form1.User_name.value.length<'4') { alert("用户名必须输入4位以上"); Form1.User_name.focus(); return false; } if(Form1.Pass_word.value.length<'6') { alert("密码必须输入6位以上"); Form1.Pass_word.focus(); return false; } return true; }}else { alert("请填入正确的11位卡号"); Form1.Card_id.focus(); return false; }}function Empty(){//Form1.User_name.value="";//Form1.Pass_word.value="";Form1.Card_id.value="";//Form1.User_name.focus();return false;}function KeyDown(){ if (event.keyCode == 13) { event.returnValue=false; event.cancel = true; Checkout(); }}</script></head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"><table border="0" cellpadding="0" cellspacing="0" width="1002"> <tr> <td align="right"> <table border="0" width="60%" id="table1" cellspacing="0" cellpadding="0"> <tr> <td> <img border="0" src="images/shang.gif" width="366" height="68" align="right" alt=""><p align="right"> </td> </tr> </table> </td> <td align="right"> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> <img border="0" src="images/query.gif" width="134" height="38" alt=""></td> </tr> <tr> <td background="images/index.gif" height="211" colspan="2" align="right" valign="top"> <table border="0" width="1002" id="table4" cellspacing="0" cellpadding="0" height="35"> <tr> <td width="167"> </td> <td width="167"> </td> <td width="167"> </td> <td width="180"> <p align="center"> </td> <td width="143"> <p align="left"> <a style="cursor:hand" onclick="Ret_new()"><img border="0" src="images/xin.gif" width="89" height="23" alt=""></a></td> <td width="178"> <a style="cursor:hand" onclick="Ret_Vip()"><img border="0" src="images/vip.gif" width="108" height="23" align="left" alt=""></a></td> </tr> </table> </td> </tr> <tr> <td colspan="2" align="center"><form method="post" name="Form1" action="/servlet"> <table border="0" width="100%" id="table3" cellspacing="0" cellpadding="2"> <tr> <td width="50%"> </td> <td width="11%" align="right"><font class="index">用户名:</font> </td> <td width="37%" align="left"> <input name="User_name" style="width:96;height:21" style="width:150,height:20" onpaste="event.returnValue=false" maxLength="10" disabled="disabled"></td> </tr> <tr> <td> </td> <td align="right"><font class="index">密 码:</font> </td> <td align="left"> <input type="password" name="Pass_word" onpaste="event.returnValue=false" style="width:96;height:21" maxLength="16" disabled="disabled"></td> </tr> <tr> <td> </td> <td align="right"><font class="index">卡 号:</font> </td> <td align="left"> <input name="Card_id" style="width:96;height:21" onpaste="event.returnValue=false" maxLength="11" onkeyup="value=value.replace(/[^\d]/g,'')"> <font color="#005F99"><span style="font-size: 9pt"> (试用期间请输入卡号直接查询)</span></font></td> </tr> <tr> <td> </td> <td align="right"> </td> <td align="left"> <input type="image" onclick="return Checkout()" border="0" src="images/b-query.gif"> <input type="image" onclick="return Empty()" border="0" src="images/b-clear.gif"></td> </tr> </table><input type="hidden" name="hiddentype" value="index"><input type="hidden" name="addr" value="180.156.108.97"></form> <p> </p> <p> </p> <table border="0" width="60%" id="table2" cellspacing="0" cellpadding="0"> <tr> <td> <p align="center"><font class="bottomcn">上海公共交通卡股份有限公司版权所有,未经授权禁止复制或建立镜像</font></td> </tr> <tr> <td> <p align="center"> <font class="bottomen">Shanghai Public Transportation Card Co.Ltd. All rights reserved</font></td> </tr> </table> </td> </tr></table></body></html>