<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    利用httpclient來模擬登陸操作

    如果有一個網站的url是http://xxx.xxx.xxx,登陸的動作是login.do其中userId表示變量名 username表示內容,密碼同理
     1 public static String getHttpContent(String loginForm, String url, String userId, String passwordId,
     2             String username, String password) throws Exception {
     3         String responseString = "";
     4         HttpClient conn = new HttpClient();
     5         if (!loginForm.equals("")) {
     6             UTF8PostMethod signinPost = new UTF8PostMethod(loginForm);
     7             signinPost.addParameter(userId, username);
     8             signinPost.addParameter(passwordId, password);
     9             conn.executeMethod(signinPost);
    10         }
    11         UTF8PostMethod postMethod = new UTF8PostMethod(url);
    12         int statusCode = conn.executeMethod(postMethod);
    13         if (statusCode > 300) {
    14             Header header = postMethod.getResponseHeader("location");
    15             String location = null;
    16             if (header != null) {
    17                 location = header.getValue();
    18                 System.out.println("The page was redirected to:" + location);
    19                 postMethod = new UTF8PostMethod(location);
    20             }
    21         }
    22         String serverPath = HttpUtils.getServerContext(url);
    23         String host = HttpUtils.gethost(url);
    24         String[] item = url.split("/");
    25         responseString = postMethod.getResponseBodyAsString();
    26         if (responseString == null)
    27             responseString = "此網址內容為空";
    28         if (item.length > 4) {
    29             if (responseString.replace("/" + item[3], item[0+ "//" + item[2+ "/" + item[3]) != null) {
    30                 responseString = responseString.replace("/" + item[3], item[0+ "//" + item[2+ "/" + item[3]);
    31             }
    32         } else {
    33             if (responseString.replace("/" + item[3], item[0+ "//" + item[2]) != null) {
    34                 responseString = responseString.replace("/" + item[3], item[0+ "//" + item[2]);
    35             }
    36         }
    37 return responseString;

    38 }



    posted on 2010-03-02 13:15 Cloud kensin 閱讀(337) 評論(0)  編輯  收藏 所屬分類: Java

    <2010年3月>
    28123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

    導航

    統計

    常用鏈接

    留言簿(4)

    隨筆分類

    相冊

    相冊

    搜索

    最新評論

    主站蜘蛛池模板: 一级人做人爰a全过程免费视频| 亚洲综合偷自成人网第页色| 污视频网站在线观看免费| 女人张开腿给人桶免费视频| 亚洲av产在线精品亚洲第一站| 亚洲啪啪免费视频| 亚洲日韩中文字幕| 免费下载成人电影| 中国china体内裑精亚洲日本| 永久免费AV无码国产网站| 国产亚洲国产bv网站在线| 午夜dj免费在线观看| 综合偷自拍亚洲乱中文字幕| 亚洲国产精品一区二区三区久久 | 亚洲AV本道一区二区三区四区| 中文字幕手机在线免费看电影| 国产亚洲精品精华液| 国产精品国产免费无码专区不卡 | 中文字幕不卡免费高清视频| 国产v亚洲v天堂无码网站| 99久久免费看国产精品| 亚洲综合校园春色| 免费看国产曰批40分钟| 久久成人永久免费播放| 国产一级一片免费播放i| caoporn国产精品免费| 久久亚洲精品成人综合| 日韩一区二区a片免费观看| 羞羞视频在线观看免费| 亚洲国产成人久久精品动漫| 最近的免费中文字幕视频| 成人a毛片视频免费看| 亚洲午夜免费视频| 四色在线精品免费观看| 中文字幕成人免费高清在线| 亚洲日韩中文字幕天堂不卡| 亚洲裸男gv网站| 91在线视频免费看| 在线观看免费黄色网址| 亚洲欧美国产日韩av野草社区| 亚洲啪啪AV无码片|