利用httpclient模拟站点的登录发帖回复
2009-09-22 00:00:00 来源:WEB开发网封装站点发帖的类SitePost:
1/** *//**
2 * Copyright (C): 2009
3 * @author 陈新汉
4 * Aug 24, 2009 5:05:55 PM
5 */
6
7/** *//**
8 * 站点发帖新帖
9 */
10public class SitePost extends CommonSitePost
11{
12
13 public SitePost(BrowserContext context) {
14 super();
15 this.context=context;
16 }
17
18 public String post(Postinfos postinfo,Siteboards siteboard) throws IOException
19 {
20 if (postinfo != null && siteboard != null) {
21 if (StringUtils.isNotEmpty(siteboard.getPostUrl())) {
22 PostMethod post = new PostMethod(siteboard.getPostUrl());
23 if(this.hasRequestParameters()){
24 post.setRequestBody(this.getRequestParams());
25 }
26 if(this.hasExtraRequestHeaders()){
27 this.addExtraRequestHeaders(post,this.getExtraRequestHeaders());
28 }
29 context.setCommonMethodRequestHeaders(post);
30 this.context.doPost(post);
31 }else{
32 System.out.println("版面的新帖提交地址不能为空!");
33 }
34 }else{
35 System.out.println("帖子或者版面信息输入都不能为空");
36 }
37 return null;
38 }
39}
40
Tags:利用 httpclient 模拟
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接