jsoup实现登录功能

public static void main(String[] args) throws IOException {
		Connection.Response res = Jsoup.connect("http://***.com/authorize")
			    .data("u", "[email protected]", "pwd", "****","k","y","op","l").ignoreContentType(true)
			    .method(Method.POST)
			    .execute();

			Document doc = res.parse();
			System.out.println(doc);
			//这儿的SESSIONID需要根据要登录的目标网站设置的session Cookie名字而定
			Map map = res.cookies(); 
			Set> entries = map.entrySet();
			Connection connection = Jsoup.connect("http://***.com/inbox");
			for(Entry entry:entries){
				connection.cookie(entry.getKey(), entry.getValue());
			}
			Document objectDoc = connection.get();
			System.out.println(objectDoc);
	}

你可能感兴趣的:(javaweb)