Skip to content

Commit

Permalink
修改demo中的设置useragent,值中去掉useragent字符
Browse files Browse the repository at this point in the history
  • Loading branch information
Arronlong committed Jan 7, 2016
1 parent fd27b7f commit c86b027
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/test/java/com/tgb/ccl/http/TestCookie.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ public static void main(String[] args) throws HttpProcessException {
//C币查询
String scoreUrl = "http://my.csdn.net/my/score";

//定义cookie存储
HttpClientContext context = new HttpClientContext();
CookieStore cookieStore = new BasicCookieStore();
context.setCookieStore(cookieStore);

//获取参数
String loginform = HttpClientUtil.send(loginUrl, context);
// System.out.println(loginform);
//System.out.println(loginform);
System.out.println("获取登录所需参数");
String lt = regex("\"lt\" value=\"([^\"]*)\"", loginform)[0];
String execution = regex("\"execution\" value=\"([^\"]*)\"", loginform)[0];
Expand All @@ -52,7 +54,7 @@ public static void main(String[] args) throws HttpProcessException {

//发送登录请求
String result = HttpClientUtil.send(loginUrl, map, context);
// System.out.println(result);
//System.out.println(result);
if(result.contains("帐号登录")){//如果有帐号登录,则说明未登录成功
String errmsg = regex("\"error-message\">([^<]*)<", result)[0];
System.err.println("登录失败:"+errmsg);
Expand Down

0 comments on commit c86b027

Please sign in to comment.