Skip to content

Commit c86b027

Browse files
committed
修改demo中的设置useragent,值中去掉useragent字符
1 parent fd27b7f commit c86b027

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/test/java/com/tgb/ccl/http/TestCookie.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ public static void main(String[] args) throws HttpProcessException {
3131
//C币查询
3232
String scoreUrl = "http://my.csdn.net/my/score";
3333

34+
//定义cookie存储
3435
HttpClientContext context = new HttpClientContext();
3536
CookieStore cookieStore = new BasicCookieStore();
3637
context.setCookieStore(cookieStore);
38+
3739
//获取参数
3840
String loginform = HttpClientUtil.send(loginUrl, context);
39-
// System.out.println(loginform);
41+
//System.out.println(loginform);
4042
System.out.println("获取登录所需参数");
4143
String lt = regex("\"lt\" value=\"([^\"]*)\"", loginform)[0];
4244
String execution = regex("\"execution\" value=\"([^\"]*)\"", loginform)[0];
@@ -52,7 +54,7 @@ public static void main(String[] args) throws HttpProcessException {
5254

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

0 commit comments

Comments
 (0)