开发学院软件开发Java 利用httpclient模拟站点的登录发帖回复 阅读

利用httpclient模拟站点的登录发帖回复

 2009-09-22 00:00:00 来源:WEB开发网   
核心提示: 封装站点发帖的类SitePost:1/***//**2*Copyright(C):20093*@author陈新汉4*Aug24,20095:05:55PM5*/67/***//**8*站点发帖新帖9*/10publicclassSitePostextendsCommonSitePost11{1

封装站点发帖的类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

上一页  1 2 3 4 5 

Tags:利用 httpclient 模拟

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接