Jsoup模擬登陸,處理重定向

hwl0420 8年前發布 | 2K 次閱讀 Java jsoup

主要這里是,有些網站登錄后,會出現重定向的問題
</div>

 

[Java]代碼    

String url = "http://crm.yazuo.com/user/check";
        Connection connection = Jsoup.connect(url);
        connection.header("Host", "crm.yazuo.com");
        connection.userAgent(UserAgent);
        connection.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
        connection.header("Accept-Language", "zh-CN,zh;q=0.8");
        connection.header("Accept-Encoding", "gzip, deflate");
        connection.header("Referer", "http://crm.yazuo.com/");
        connection.header("Upgrade-Insecure-Requests", "1");
        connection.header("Origin", "http://crm.yazuo.com");
        connection.header("Content-Type", "application/x-www-form-urlencoded");
        connection.header("Connection", "keep-alive");
        connection.header("Cache-Control", "max-age=0");
        connection.header("Cookie", cookie);
        connection.data("Mobile", "XXXXXXX");
        connection.data("Upwd", "XXXX");
        connection.data("remember_me", "1");
        connection.method(Connection.Method.POST);
        connection.followRedirects(false);//此行必須添加
 本文由用戶 hwl0420 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!