Java SSH最新的可行的模拟登录163,126,yeah,tom,sina,sohu等邮箱,并且解析出好友列表
2011-11-10 14:47
495 查看
这边只列举出163的 其他的可以联系本人购买价格面议 可免费升级。
需要的 给我发邮件: sl514@163.com
项目运行结果:
需要的 给我发邮件: sl514@163.com
package com.d1xn.invite.mailImportor.mailImporter; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.http.NameValuePair; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.message.BasicNameValuePair; import org.apache.log4j.Logger; import com.d1xn.core.config.CoreErrorCode; import com.d1xn.core.util.IOUtil; import com.d1xn.invite.config.InviteErrorCode; import com.d1xn.invite.mailImportor.common.ContactImpl; import com.d1xn.invite.mailImportor.common.ContactListImporterImpl; import com.d1xn.invite.mailImportor.user.Contact; import com.d1xn.invite.mailImportor.util.StringUtil; /** * 网易163邮箱导入对象 * * @author shaliang * @blog www.ij2ee.com * */ public class Mail163Importer extends ContactListImporterImpl { @Override /** * 登录 */ protected int login(DefaultHttpClient client) throws Exception { //log.info(this.getemail()); NameValuePair data[] = { new BasicNameValuePair(".verifycookie", "1"), new BasicNameValuePair("style", "35"), new BasicNameValuePair("product", "mail163"), new BasicNameValuePair("username", this.getUsername()), new BasicNameValuePair("password", this.getPassword()), new BasicNameValuePair("selType=", "jy"), new BasicNameValuePair("remUser", "on"), new BasicNameValuePair("secure", "on") }; long time = System.currentTimeMillis(); BasicClientCookie cookie = new BasicClientCookie("163_LOGIN", (new StringBuilder("T")).append(time).append("/").append( time - 16L).append("/").append(time).toString()); client.getCookieStore().addCookie(cookie); log.info(cookie); String loginPageUrl = getLoginURL() + "&d=" + System.currentTimeMillis(); log.info("Requesting login page"); //发送post请求 获取响应字符串 String content = readInputStream(doPost(client, loginPageUrl, data, ""),null); if (content.contains("window.location.replace")) { log.info("redirecting"); } else { log .info("Login failed, username or password do not match please check your name&password"); return CoreErrorCode.ACCOUNT_OR_PASSWORD_ERROR; } String reUrl = content.substring(content.indexOf("window.location.replace(\"") + 25); reUrl = reUrl.substring(0, reUrl.indexOf("\")")); InputStream is = doGet(client, reUrl, null); content = readInputStream(is,null); String sessId = null; if (content.contains("index.jsp?sid=")) { String regex = "index.jsp\\?sid=([^\\\"]+)"; sessId = StringUtil.getByRegex(regex, 1, content); tempSessId = sessId; } return InviteErrorCode.INVITE_OPERATE_SUCCESS; } /** * 从指定流中解析出联系人集合 * * @param is * 指定的流对象 * @return 解析后得到的联系人集合 */ @Override protected List<Contact> parseContacts(InputStream is) throws Exception { // TODO Auto-generated method stub List<Contact> contactList = new ArrayList<Contact>(); String line = readInputStream(is,"utf-8"); is.close(); System.err.println(line); String aa = "<div class=\"gTitleSub\"><div align=\"left\"><b class=\"mTT\">([^<]+)</b></div><div class=\"Extra\"></div></div><table class=\"gTable\"><tr id=\"tr_base_0\" style=\"\"><th>[^<]+</th><td>([^<]+)</td></tr>"; Pattern p = Pattern.compile(aa); Matcher m = p.matcher(line); int groupNum = 0; int firstIndex = 0; while(m.find(firstIndex)) { String name = m.group(1); String email = m.group(2); contactList.add(new ContactImpl(name,email)); firstIndex = m.end(); groupNum++; } return contactList; } private Logger log = Logger.getLogger(this.getClass()); private String tempSessId = ""; private String loginURL; private String contactListURL; public Mail163Importer() { } public Mail163Importer(String username, String password) { super(username, password); } public void setLoginInfo(String email, String password) { super.setLoginInfo(email, password); } public void setLoginURL(String loginURL) { this.loginURL = loginURL; } public void setContactListURL(String contactListURL) { this.contactListURL = contactListURL + this.tempSessId; } public void setTempSessId(String tempSessId) { this.tempSessId = tempSessId; } @Override public String getContactListURL() { return this.contactListURL + tempSessId; } @Override public String getLoginURL() { return this.loginURL; } }
项目运行结果:
相关文章推荐
- java在线聊天项目1.3版设计好友列表框功能补充,因只要用户登录就发送一串新列表,导致不同客户端好友列表不同问题
- java模拟登录校内成绩查询网站,将获得的HTML代码用jsoup解析
- Sina、sohu、tom、163、baidu、google域名服务器测评
- php curl 登录163邮箱并抓取邮箱好友列表的代码(经测试)
- 【JavaWeb】XML文件_使用xml文件作为数据库并且使用xpath技术模拟用户登录
- 阿兹猫 的 Java模拟登陆QQ邮箱获取好友列表的实现
- [置顶]Java丨jsoup网络爬虫模拟登录思路解析
- 第三方邮箱登录126,163等服务器配置STMP
- Sina微博模拟登录获取Cookies (v1.3.16)
- 使用java自动爬取新浪微博历史列表-免登录
- 分享读取各大主流邮箱通讯录(联系人)、MSN好友列表的的功能【升级版(3.0)】
- 模拟用户登录情景,并且只能登录三次
- Android(Java) 模拟登录知乎并抓取用户信息
- java poi 解析excel 输出json 并且拼接字符串显示到jsp
- java在线聊天项目1.2版 ——开启多个客户端,分别实现数据库注册和登录功能后,成功登陆则登录框消失,好友列表窗出现
- 最新SSH自动登录方案(RSA)
- 获取邮箱通讯录,msn好友列表的C#源码
- 【微信公众平台改版后】Java模拟登录微信平台,主动推送消息给用户