浏览 2999 次
锁定老帖子 主题:用GAE开发了一个开心网外挂,开源了
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-09-19
源代码放在Google code中,详细介绍:http://bit.ly/1Lle0N 关键代码 /** * 打工 * @param resultBuilder * @param verifyValue */ private void processJob(String verifyValue){ StringBuilder resultBuilder = getHttpContent(URL_PREFIX_HOUSE_JOB+verifyValue); String result = resultBuilder.toString(); int jobIdPos = result.lastIndexOf("<option value=\""); String sMaxJobId = findText(result, "<option value=\"", "\"", jobIdPos); if (sMaxJobId == null) return; //prepare post // petid=12&verify=11111_111111_121212829_e33f851c27b60165ac0e7b9156ba01e6_kx StringBuilder postData = new StringBuilder() .append("petid=").append(sMaxJobId) .append("&verify=").append(verifyValue) ; StringBuilder doJobResult = postHttpContent(URL_PREFIX_HOUSE_JOB_DO, postData.toString(), URL_PREFIX_HOUSE_JOB+verifyValue); if (doJobResult==null) return; String sDoJobResult = findText(doJobResult.toString(), "<div class=\"tips1\">", "<br/>", 0); logBuilder.append(sDoJobResult).append("\r\n"); } 收获菜地 private void harvest(String url){ StringBuilder resultBuilder = getHttpContent(url); if (resultBuilder!=null){ String sGarden = resultBuilder.toString(); //收获 int indexUrl = sGarden.indexOf("garden/havest.php?"); String havestUrl = null; while((havestUrl=findText(sGarden, "garden/havest.php?", "\"", indexUrl))!=null){ indexUrl = sGarden.indexOf("garden/havest.php?", indexUrl)+1; havestUrl = URL_PREFIX_HOUSE_GARDEN_HAVEST+havestUrl; havestUrl = havestUrl.replaceAll("&", "&"); StringBuilder havestBuilder = getHttpContent(havestUrl); if (havestBuilder != null){ String sHavest = havestBuilder.toString(); String what = findText(sHavest, "你已经收获了", "</div>", 0); if (what != null){ logBuilder.append("收获了"+what).append("\r\n"); } else{ what = findText(sHavest, "你已经成功偷到", "</div>", 0); if (what != null){ logBuilder.append("偷到"+what).append("\r\n"); } } } } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |