WEB开发网
开发学院软件开发Java 模拟站点的自动登录发帖回复 阅读

模拟站点的自动登录发帖回复

 2009-09-21 00:00:00 来源:WEB开发网   
核心提示: Java代码 /***站点发帖新帖*/publicclassSitePostextendsCommonSitePost{publicSitePost(BrowserContextcontext){super();this.context=context;}publicStringpost(Pos

Java代码 模拟站点的自动登录发帖回复

/**
 * 站点发帖新帖
*/
public class SitePost extends CommonSitePost
{
  public SitePost(BrowserContext context) {
    super();
    this.context=context;
  }
  public String post(Postinfos postinfo,Siteboards siteboard) throws IOException
  {
    if (postinfo != null && siteboard != null) {
      if (StringUtils.isNotEmpty(siteboard.getPostUrl())) {
        PostMethod post = new PostMethod(siteboard.getPostUrl());
        if(this.hasRequestParameters()){
          post.setRequestBody(this.getRequestParams());
        }
        if(this.hasExtraRequestHeaders()){
          this.addExtraRequestHeaders(post,this.getExtraRequestHeaders());
        }
        context.setCommonMethodRequestHeaders(post);
        this.context.doPost(post);
      }else{
        System.out.println("版面的新帖提交地址不能为空!");
      }
    }else{
      System.out.println("帖子或者版面信息输入都不能为空");
    }
    return null;
  }
}

上一页  1 2 3 4 5 

Tags:模拟 站点 自动

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接