51job.com(前程无忧)和chinahr.com(中华英才网)企业用户登录DEMO
这个例子是昨天我帮一个用户开发的,也是费了我不少功夫。现在放到这里
大家有需要的可以支付10元进行下载
代码预览
大家在使用时直接调用这两个方法就OK了,
里面使用的是我最新的Httphelper类。
源码
51job&chinahr.rar
(13.86 KB, 下载次数: 129)
调用如下
[C#] 纯文本查看 复制代码 ////中华英才网企业用户登录
//string html = GetZhonghuaHtml("用户名", "密码");
//51job企业用户登录
string html = Get51JobHtml("账户", "公司名", "密码");
Response.Write(html);
个人登录直接查看
[C#] 纯文本查看 复制代码 /// <summary>
/// 获取51job网的登录信息
/// </summary>
/// <param name="user">账户</param>
/// <param name="pwd">密码</param>
/// <returns>Cookie</returns>
private string Get51JobHtml(string user, string pwd)
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://my.51job.com/my/My_SignIn.php",//URL 必需项
};
HttpResult result = http.GetHtml(item);
string actionurl =Regex.Match(result.Html,"action=\"([url]https://mylogin.51job.com/[/url]\\d{10,50}/my/My_Pmc.php)\"").Groups[1].Value.ToString() ;
item = new HttpItem()
{
URL =actionurl,//URL 必需项
Method = "post",//URL 可选项 默认为Get
Postdata = "username=" + HttpHelper.URLEncode(user) + "&userpwd=" + HttpHelper.URLEncode(pwd) + "&login_verify=&url=&x=0&y=0",
ContentType="application/x-www-form-urlencoded",
};
result = http.GetHtml(item);
string cookie = result.Cookie;
item = new HttpItem()
{
URL = result.RedirectUrl,//URL 必需项
Method = "get",//URL 可选项 默认为Get
Cookie = cookie.Replace("path=/;", string.Empty).Replace("domain=.51job.com", string.Empty).Replace(",",string.Empty),//字符串Cookie 可选项
};
result = http.GetHtml(item);
string html = result.Html;
cookie = result.Cookie;
return html;
}
|