<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 閱讀(346) 評論(0)  編輯  收藏 所屬分類: Java

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

    導航

    統計

    常用鏈接

    留言簿(4)

    隨筆分類

    相冊

    相冊

    搜索

    最新評論

    主站蜘蛛池模板: 亚洲午夜久久久久久尤物| 亚洲午夜免费视频| 亚洲va中文字幕| 亚洲精品动漫免费二区| 亚洲AV无码专区在线亚| 日本三级2019在线观看免费| 中文字幕亚洲免费无线观看日本| 免费国产黄网站在线观看| 亚洲欧洲在线观看| 久久久久久夜精品精品免费啦| 久久久久亚洲精品影视| 亚洲视频在线观看免费| 亚洲欧洲精品在线| 大学生一级特黄的免费大片视频| 亚洲一区二区三区深夜天堂| 成年美女黄网站18禁免费 | 亚洲精品无码久久久影院相关影片| 免费福利在线观看| 亚洲午夜av影院| 免费看少妇高潮成人片| 亚洲欧洲国产精品你懂的| 99无码人妻一区二区三区免费| 亚洲夂夂婷婷色拍WW47 | 亚洲无码黄色网址| 日本免费高清视频| 亚洲va成无码人在线观看| 日韩高清免费观看| XXX2高清在线观看免费视频| 亚洲国产精品第一区二区| 大地资源免费更新在线播放 | 亚洲综合精品第一页| 免费国产精品视频| 久久青草精品38国产免费| 亚洲一卡2卡3卡4卡乱码 在线| 四虎影视永久免费观看网址| 久久久精品视频免费观看| 亚洲图片中文字幕| 亚洲黄黄黄网站在线观看| 99久久人妻精品免费二区| 亚洲AV无码成人精品区日韩 | 亚洲韩国—中文字幕|