模拟站点的自动登录发帖回复
2009-09-21 00:00:00 来源:WEB开发网Java代码
/*
6
7/** *//**
8 * 模拟测试网站(不需要验证码)
9 * 开心网(www.kaixin.com)
*/
public class KaixinSitePost implements ISitePost
{
private static final String LOGON_SITE = "www.kaixin.com";
private static final int LOGON_PORT = 80;
private static final String CHARSET="UTF-8";
private BrowserContext context=null;
//单个用户登录
public String login(Siteusers userinfo, Proxyips ip)
{
if(userinfo!=null)
{
SiteLogin login=new SiteLogin(context,"http://login.kaixin.com/Login.do");
if(ip!=null)
login.getContext().setProxyip(ip);
Map<String,String> params=new HashMap<String,String>();
params.put("ss", "10106");
params.put("loginregFrom", "index");
params.put("origURL", "http://www.kaixin.com/SysHome.do");
params.put("email", userinfo.getUsername());
params.put("password", userinfo.getUserpwd());
login.addRequestParameters(params);
return login.login(userinfo);
}
return null;
}
public List<Siteboards> parseBoard(Siteboards data) {
return null;
}
public String post(Postinfos postinfo,List<Siteboards> siteboards)
{
if(postinfo!=null && siteboards!=null){
SitePost sport=new SitePost(context);
context.getClient().getHostConfiguration().setHost("blog.kaixin.com");
Map<String,String> params=new HashMap<String,String>();
params.put("categoryId", "0");
params.put("blogControl", "1");
params.put("title", postinfo.getTitle());
params.put("body",postinfo.getContent());
sport.addRequestParameters(params);
for(Siteboards sb:siteboards){
sb.setPostUrl("http://blog.kaixin.com/NewEntry.do");
try{
sport.post(postinfo, sb);
}catch(IOException e){
e.printStackTrace();
}
}
}
return null;
}
public String reply(Postinfos postinfo,List<Articleinfos> arts)
{
return null;
}
/** *//**
* @param args
*/
public static void main(String[] args)
{
try
{
Siteusers userinfo=new Siteusers();
userinfo.setUsername("xxxx");
userinfo.setUserpwd("xxxx");
Proxyips ips = new Proxyips();
ips.setIp("218.56.64.210");
ips.setPort(8080);
KaixinSitePost sp=new KaixinSitePost();
sp.login(userinfo,ips);
Postinfos post=new Postinfos();
post.setContent("<p>lllllllllllllllllllllll</p>");
post.setTitle("中文测试");
List<Siteboards> siteboards=new ArrayList<Siteboards>();
siteboards.add(new Siteboards());
siteboards.add(new Siteboards());
sp.post(post,siteboards);
}
catch(Exception e){
e.printStackTrace();
}
}
}
更多精彩
赞助商链接