public DataTable WrAddMenu(string PMenuId, string ParentId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrAddMenu(PMenuId, ParentId, dbConnectionString, dbPassword)); } }
public bool WrDelMenu(string MenuId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrDelMenu(MenuId, dbConnectionString, dbPassword)); } }
// Return MasterTable given Screen ID and DB Column Id. public string WrGetMasterTable(string ScreenId, string ColumnId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetMasterTable(ScreenId, ColumnId, dbConnectionString, dbPassword)); } }
public Dictionary <string, IEnumerable <Tag> > GetTags(string appKey, string uids) { string url = string.Format("http://api.weibo.com/2/tags/tags_batch.json?source={0}&uids={1}", appKey, uids); string html = new WebAccessBase().GetHTML(url); if (html == null) { return(null); } var json = JArray.Parse(html); var result = new Dictionary <string, IEnumerable <Tag> >(); foreach (var item in json) { var entry = item["id"].ToString(); List <Tag> list = new List <Tag>(); foreach (var jToken in item["tags"]) { var obj = (JObject)jToken; var first = (JProperty)obj.First; var last = (JProperty)obj.Last; list.Add(new Tag { ID = first.Name, Name = string.Format("{0}", first.Value), Weight = string.Format("{0}", last.Value) }); } result.Add(entry, list); } return(result); }
// Return column details from physical database. public string WrSyncByDb(int UsrId, byte SystemId, byte DbId, string TableId, string TableName, string TableDesc, bool MultiDesignDb, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrSyncByDb(UsrId, SystemId, DbId, TableId, TableName, TableDesc, MultiDesignDb, dbConnectionString, dbPassword)); } }
public void WrUpdScreenObj(string ScreenObjId, string PScreenObjId, string TabFolderId, string ColumnHeader, string CultureId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { dac.WrUpdScreenObj(ScreenObjId, PScreenObjId, TabFolderId, ColumnHeader, CultureId, dbConnectionString, dbPassword); } }
// For report generator: public DataTable GetDdlOriColumnId33S1682(string rptwizCatId, bool bAll, string keyId, string dbConnectionString, string dbPassword, UsrImpr ui, UsrCurr uc, Int16 cultureId) { using (WebAccessBase dac = GetWebAccess()) { return(dac.GetDdlOriColumnId33S1682(rptwizCatId, bAll, keyId, dbConnectionString, dbPassword, ui, uc, cultureId)); } }
public void WrUpdScreenTab(string ScreenTabId, string TabFolderOrder, string TabFolderName, string CultureId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { dac.WrUpdScreenTab(ScreenTabId, TabFolderOrder, TabFolderName, CultureId, dbConnectionString, dbPassword); } }
public DataTable WrGetAdmMenuPerm(Int32 screenId, string keyId58, string dbConnectionString, string dbPassword, Int32 screenFilterId, UsrImpr ui, UsrCurr uc) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetAdmMenuPerm(screenId, keyId58, dbConnectionString, dbPassword, screenFilterId, ui, uc)); } }
public Int32 CountEmailsSent() { using (WebAccessBase dac = GetWebAccess()) { return(dac.CountEmailsSent()); } }
// Return default CultureId or CultureTypeName as a string. public string WrGetDefCulture(bool bCultureId) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetDefCulture(bCultureId)); } }
// Replace GetDdlPermId3S1751: public DataTable WrGetDdlPermId(string PermKeyId, Int32 ScreenId, Int32 TableId, bool bAll, string keyId, string dbConnectionString, string dbPassword, UsrImpr ui, UsrCurr uc) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetDdlPermId(PermKeyId, ScreenId, TableId, bAll, keyId, dbConnectionString, dbPassword, ui, uc)); } }
// Create a copy of report template based on report wizard in advanced report definition. public bool WrXferRpt(Int32 ReportId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrXferRpt(ReportId, dbConnectionString, dbPassword)); } }
public void WrUpdMenu(string MenuId, string PMenuId, string ParentId, string MenuText, string CultureId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { dac.WrUpdMenu(MenuId, PMenuId, ParentId, MenuText, CultureId, dbConnectionString, dbPassword); } }
public DataTable GetDdlSelColumnId77S1682(Int32 screenId, bool bAll, string keyId, string filterId, string dbConnectionString, string dbPassword, UsrImpr ui, UsrCurr uc, Int16 cultureId) { using (WebAccessBase dac = GetWebAccess()) { return(dac.GetDdlSelColumnId77S1682(screenId, bAll, keyId, filterId, dbConnectionString, dbPassword, ui, uc, cultureId)); } }
public DataTable WrAddScreenTab(string TabFolderOrder, string ScreenId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrAddScreenTab(TabFolderOrder, ScreenId, dbConnectionString, dbPassword)); } }
public DataTable GetDdlOperator3S1652(string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.GetDdlOperator3S1652(dbConnectionString, dbPassword)); } }
public DataTable WrAddScreenObj(string ScreenId, string PScreenObjId, string TabFolderId, bool IsTab, bool NewRow, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrAddScreenObj(ScreenId, PScreenObjId, TabFolderId, IsTab, NewRow, dbConnectionString, dbPassword)); } }
// Obtain table-valued function from the physical database for virtual table. public string WrGetVirtualTbl(string TableId, byte DbId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetVirtualTbl(TableId, DbId, dbConnectionString, dbPassword)); } }
public bool WrDelScreenObj(string ScreenObjId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrDelScreenObj(ScreenObjId, dbConnectionString, dbPassword)); } }
public bool UpdAdmRptWiz95(LoginUsr LUser, UsrCurr LCurr, DataSet ds, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.UpdAdmRptWiz95(LUser, LCurr, ds, dbConnectionString, dbPassword)); } }
// Return ScreenId given program name. public string WrGetScreenId(string ProgramName, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetScreenId(ProgramName, dbConnectionString, dbPassword)); } }
public void RmTranslatedLbl(string LabelId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { dac.RmTranslatedLbl(LabelId, dbConnectionString, dbPassword); } }
public DataTable WrGetScreenObj(string ScreenId, Int16 CultureId, string ScreenObjId, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetScreenObj(ScreenId, CultureId, ScreenObjId, dbConnectionString, dbPassword)); } }
/// <summary> /// 发微博 /// </summary> /// <param name="web"></param> /// <param name="text"></param> /// <param name="pic">picID</param> /// <param name="appkey"></param> /// <returns></returns> public static string AddMblog(WebAccessBase web, string text, string pic = null, string appkey = null) { if (web == null) throw new ArgumentNullException("web"); if (string.IsNullOrEmpty(text)) throw new ArgumentNullException("text", "微博内容不能为空"); if (Encoding.GetEncoding("GBK").GetByteCount(text) > 280) return "文本内容超出140字"; web.Encode = Encoding.UTF8; web.Reffer = new Uri("http://m.weibo.cn/"); web.GetHTML("http://m.weibo.cn/mblog"); const string postUrl = "http://m.weibo.cn/mblogDeal/addAMblog"; var postData = string.IsNullOrEmpty(pic) ? string.Format("content={0}", Uri.EscapeDataString(text)) : string.Format("content={0}&picId={1}", Uri.EscapeDataString(text), pic); if (!string.IsNullOrEmpty(appkey)) { postData += string.Format("&appkey={0}", appkey); } var html = web.PostWithHeaders(postUrl, postData, new[] { "X-Requested-With: XMLHttpRequest" }); //发微博结果分析 string res = html.CommonAnalyse("发微博"); return res; }
// Get email and other info for a specific user. public DataTable WrGetUsrEmail(string UsrId) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrGetUsrEmail(UsrId)); } }
/// <summary> /// 构造函数 /// </summary> public ComWeiboLogin() { Web = new WebAccessBase { TimeOut = 60000 }; _ruoKuaiClient = RuoKuaiClient.CreateInstance(); CurrPlatformType = PlatformType.Com; Error = "未执行"; }
/// <summary> /// 获取新增粉丝 /// </summary> /// <param name="web"></param> /// <returns></returns> public static string GetNewFans(WebAccessBase web) { web.Reffer = new Uri("http://m.weibo.cn/"); const string url = "http://m.weibo.cn/p/index?containerid=103103"; return(web.GetHTML(url)); }
public Yunma(string username, string password) { _web = new WebAccessBase { TimeOut = 60000 }; const string url = BaseUrl + "loginIn"; string postData = string.Format("uid={0}&pwd={1}", username, password); string html = _web.Post(url, postData); if (string.IsNullOrEmpty(html) || !html.Contains("Token")) { throw new Exception("云码初始化失败"); } try { var json = DynamicJson.Parse(html); _uid = json.Uid; _token = json.Token; Balance = json.Balance; } catch (Exception) { throw new Exception("云码初始化失败"); } }
// Generate or synchronize report template based on report wizard. public string WrRptwizGen(Int32 RptwizId, string SystemId, string AppDatabase, string dbConnectionString, string dbPassword) { using (WebAccessBase dac = GetWebAccess()) { return(dac.WrRptwizGen(RptwizId, SystemId, AppDatabase, dbConnectionString, dbPassword)); } }
/// <summary> /// 发表微博 /// </summary> /// <param name="web"></param> /// <param name="text">需要发布的文本内容</param> /// <param name="pic"></param> /// <param name="appkey"></param> /// <returns></returns> public static string AddMblog(WebAccessBase web, string text, string pic = null, string appkey = null) { if (web == null) { throw new ArgumentNullException("web"); } if (string.IsNullOrEmpty(text)) { throw new ArgumentNullException("text", "微博内容不能为空"); } web.Encode = Encoding.UTF8; web.Reffer = new Uri("http://weibo.com/"); var url = string.Format("http://weibo.com/aj/mblog/add?ajwvr=6&__rnd={0}", CommonExtension.GetTime()); var postData = string.Format( "location=v6_content_home&appkey={2}&style_type=1&pic_id={1}&text={0}&pdetail=&rank=0&rankid=&module=stissue&pub_type=dialog&_t=0", text, pic, appkey); var htmlMsg = web.PostWithHeaders(url, postData, new[] { "X-Requested-With: XMLHttpRequest" }); if (!string.IsNullOrEmpty(htmlMsg) && htmlMsg.Contains("\"code\":\"100000\"")) { return(""); } ComHttpWorkLogger.Info(string.Format("发微博失败\r\n{0}", htmlMsg)); return(string.Format("发微博失败")); }
/// <summary> /// 删除微博 /// </summary> /// <param name="web"></param> /// <param name="url"></param> /// <param name="mid"></param> /// <returns></returns> public static string DelMblog(WebAccessBase web, string url, string mid) { web.Reffer = new Uri("http://weibo.com/"); var weiboStr = web.GetHTML(url); if (string.IsNullOrEmpty(weiboStr)) { ComHttpWorkLogger.Info("访问微博{0}页面出错", url); return("网络错误 删除微博"); } if (weiboStr.Contains("<script>parent.window.location=\"http://weibo.com/sorry?pagenotfound\"</script>")) { return("微博不存在"); } const string posturl = "http://weibo.com/aj/mblog/del?ajwvr=6"; var postData = "mid=" + mid; var htmlMsg = web.PostWithHeaders(posturl, postData, new[] { "X-Requested-With: XMLHttpRequest" }); if (!string.IsNullOrEmpty(htmlMsg) && htmlMsg.Contains("\"code\":\"100000\"")) { return(""); } ComHttpWorkLogger.Info(string.Format("删除微博失败\r\n{0}", htmlMsg)); return(string.Format("删除微博失败")); }
/// <summary> /// 根据用户信息和页码获取用户的10条微博 /// </summary> /// <param name="web"></param> /// <param name="weiboUser"></param> /// <param name="page"></param> /// <returns></returns> public static string GetMultiMblog(WebAccessBase web, Entity weiboUser, int page) { var reffer = string.Format("http://m.weibo.cn/u/{0}", weiboUser.ID); web.Reffer = new Uri(reffer); var url = string.Format("http://m.weibo.cn/page/json?containerid={0}_-_WEIBO_SECOND_PROFILE_WEIBO&page={1}", weiboUser.IDStr, page); return web.GetHTML(url); }
/// <summary> /// 获取用户主页的信息 /// </summary> /// <param name="web"></param> /// <param name="uid">用户</param> /// <returns></returns> public static string GetUser(WebAccessBase web, string uid) { web.Reffer = null; //获取主页 var url = string.Format("http://m.weibo.cn/u/{0}", uid); return web.GetHTML(url); }
/// <summary> /// 构造函数 /// </summary> public CNWeiboLogin() { Web = new WebAccessBase ("Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A405 Safari/8536.25") { TimeOut = 60000 }; _ruoKuaiClient = RuoKuaiClient.CreateInstance(); CurrPlatformType = PlatformType.CN; Error = "未执行"; }
public Yzm1(string username, string password) { web = new WebAccessBase { TimeOut = 60000 }; string postData = string.Format("action=loginIn&name={0}&password={1}", username, password); string html = web.Post(url, postData); const string str = @"1\|[A-Fa-f0-9]{8}(-[A-Fa-f0-9]{4}){3}-[A-Fa-f0-9]{12}$"; Regex reg = new Regex(str); if (!string.IsNullOrEmpty(html) && reg.IsMatch(html)) { token = html.Split('|')[1]; } else throw new Exception("壹码初始化失败"); }
public F02(string uid, string pwd) { web = new WebAccessBase { TimeOut = 60000 }; string postData = string.Format("action=loginIn&uid={0}&pwd={1}", uid, pwd); string html = web.Post(url, postData); string str = @"^" + uid + @"\|[0-9a-f]{32}$"; Regex reg = new Regex(str); if (!string.IsNullOrEmpty(html) && reg.IsMatch(html)) { token = html.Split('|')[1]; this.uid = uid; } else throw new Exception("爱码初始化失败"); }
public Taoma(string username, string password) { _username = username; _passwordMd5 = Md5Encrypt(password); _web = new WebAccessBase { TimeOut = 60000 }; }
public JikeSms(string uid, string pwd) { _web = new WebAccessBase { TimeOut = 60000 }; if (!Login(uid, pwd)) throw new Exception("初始化JikeSMS失败"); }
public Collection GetUserEntityColloction(string appKey, string uids) { string url = string.Format("http://api.weibo.com/2/users/show_batch.json?source={0}&uids={1}", appKey, uids); string html = new WebAccessBase().GetHTML(url); if (html == null) { return null; } var t = JsonConvert.DeserializeObject<Collection>(html); return t; }
public Dictionary<string, IEnumerable<Tag>> GetTags(string appKey, string uids) { string url = string.Format("http://api.weibo.com/2/tags/tags_batch.json?source={0}&uids={1}", appKey, uids); string html = new WebAccessBase().GetHTML(url); if (html == null) { return null; } var json = JArray.Parse(html); var result = new Dictionary<string, IEnumerable<Tag>>(); foreach (var item in json) { var entry = item["id"].ToString(); List<Tag> list = new List<Tag>(); foreach (var jToken in item["tags"]) { var obj = (JObject)jToken; var first = (JProperty)obj.First; var last = (JProperty)obj.Last; list.Add(new Tag { ID = first.Name, Name = string.Format("{0}", first.Value), Weight = string.Format("{0}", last.Value) }); } result.Add(entry, list); } return result; }
public string Run2(string username, string password) { WebAccessBase web = new WebAccessBase(); try { //web.Encode = Encoding.GetEncoding("gb2312"); //web.Reffer = new Uri("http://weibo.com/"); //var html = web.GetHTML("http://login.sina.com.cn/member/testify/testify.php?entry=weibo"); //if (!string.IsNullOrEmpty(html) && html.Contains("填写登录帐号")) //{ // var regex = new Regex(@"<input type=""hidden"".*?name=""(.*?)"" value=""(.*?)"">"); // var temp = regex.Matches(html) // .Cast<Match>() // .Aggregate("", // (current, match) => current + (match.Groups[1].Value + "=" + match.Groups[2].Value + "&")); // temp += "username="******"&"; // temp += "password="******"http://login.sina.com.cn/member/testify/testify2.php", temp); // if (!string.IsNullOrEmpty(html) && html.Contains("填写手机号验证帐号")) // { // for (int i = 0; i < 30; i++) // { // //取手机号 // string mobile = GetMobile(_type2); // if (mobile == "获取手机号失败") // return "获取手机号失败"; // temp = regex.Matches(html) // .Cast<Match>() // .Aggregate("", // (current, match) => // current + (match.Groups[1].Value + "=" + match.Groups[2].Value + "&")); // temp += "scellphone=" + mobile + "&entry=weibo&loginname=" + username.Replace("@", "%40"); // var url = "http://login.sina.com.cn/member/testify/testify3_sms.php?rnd=" + // new Random(Guid.NewGuid().GetHashCode()).NextDouble(); // html = web.Post(url, temp); // if (!string.IsNullOrEmpty(html) && html.Contains("A00006")) // { // #region 收短信 // string rencode = ""; // int count = 0; // while (rencode.Length != 6) //收激活码 // { // if (count > 10) //工作1分钟后退出 // { // //SMSApi.SMSApi.cancelSMSRecvAll(sms_username, token); // //_smsapi.CancelSmsRecvAll(); // _smsapi.AddIgnoreList(mobile); // return "接受手机验证码超时" + rencode; // } // Thread.Sleep(5000); // rencode = _smsapi.Unlock(mobile, _type2); //爱码是123,飞Q是48 // //if (rencode.Equals("mobile_state_error") || rencode.Equals("parameter_error")) // //{ // // //_smsapi.CancelSmsRecvAll(); // // _smsapi.AddIgnoreList(mobile); // // return "接受手机验证码错误" + rencode; // //} // //if (verified.Length > 6 && !verified.Equals("not_receive")) // //if (rencode.Length == 6) // // File.AppendAllText("VerifiedLog.txt", // // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\t手机号\t" + mobile + "\t" + // // rencode + Environment.NewLine); // count++; // } // #endregion // temp = temp.Replace("scellphone=" + mobile, "rencode=" + rencode); // url = "http://login.sina.com.cn/member/testify/testify4.php?rnd=" + // new Random(Guid.NewGuid().GetHashCode()).NextDouble(); // web.Reffer = new Uri("http://login.sina.com.cn/member/testify/testify2.php"); // html = web.Post(url, temp); // if (!string.IsNullOrEmpty(html) && html.Contains("A00006")) // { // //var result = DynamicJson.Parse(html); // //url = result.data.url; // //html = web.GetHTML(url); // return "解封成功"; // } // } // else // { // _smsapi.AddIgnoreList(mobile, _type2); // //_smsapi.CancelSmsRecvAll(); // } // } // return "账号解封但经过多次尝试没有可用手机号"; // } // return "账号解封但未进入填写手机号验证帐号页面"; //} return "账号解封但未进入填写登录帐号页面"; } catch (Exception) { return "解封异常"; } }
/// <summary> /// 获取新增粉丝的第一页 /// </summary> /// <param name="web"></param> public static List<string> GetNewFans(WebAccessBase web) { var newFansPage = GetCnPage.GetNewFans(web); if (string.IsNullOrEmpty(newFansPage)) { CNHttpWorkLogger.Info("访问新增粉丝页面出错"); return new List<string>(); } return AnalyseCnPage.AnalysisNewFansPage(newFansPage); }
/// <summary> /// 取消关注 /// </summary> /// <param name="web"></param> /// <param name="uid"></param> /// <returns></returns> public static string FriendDestroy(WebAccessBase web, string uid) { if (web == null) throw new ArgumentNullException("web"); if (string.IsNullOrEmpty(uid)) throw new ArgumentNullException("uid"); web.Encode = Encoding.UTF8; web.Reffer = null; var home = web.GetHTML(string.Format("http://weibo.com/u/{0}", uid)); if (string.IsNullOrEmpty(home)) { return string.Format("访问关注对象{0}页面出错", uid); } if (home.Contains("<title>404错误</title>")) { return "工作对象被封"; } var oid = OidRegex.Match(home).Groups["oid"].Value; var location = LocationRegex.Match(home).Groups["location"].Value; var nick = NickRegex.Match(home).Groups["onick"].Value; if (string.IsNullOrEmpty(oid) || string.IsNullOrEmpty(location) || string.IsNullOrEmpty(nick)) { ComHttpWorkLogger.Info("分析关注对象{0}页面出错\r\n{1}", uid, home); return string.Format("分析关注对象{0}页面出错", uid); } if (uid != oid) { ComHttpWorkLogger.Info("分析关注对象{0}页面UID出错\r\n{1}", uid, home); return string.Format("分析关注对象{0}页面UID出错", uid); } var postUrl = string.Format("http://weibo.com/aj/f/unfollow?ajwvr=6"); var postData = string.Format( "uid={0}&objectid=&f=1&extra=&refer_sort=&refer_flag=&location={1}&oid={2}&wforce=1&nogroup=false&fnick={3}", uid, location, oid, nick); var postHtml = web.PostWithHeaders(postUrl, postData, new[] { "X-Requested-With: XMLHttpRequest" }); //取消关注结果分析 if (string.IsNullOrEmpty(postHtml)) { return "取消关注失败,返回空"; } try { dynamic postResult = DynamicJson.Parse(postHtml); return postResult.code == "100000" ? "" : string.Format("取消关注失败,{0}", postResult.msg); } catch (Exception) { ComHttpWorkLogger.Info(string.Format("取消关注失败\r\n{0}", postHtml)); return "取消关注失败,分析失败"; } }
/// <summary> /// 点赞 /// </summary> /// <param name="web"></param> /// <param name="weiboUrl"></param> /// <param name="weiboId"></param> /// <returns></returns> public static string AttitudesCreate(WebAccessBase web, string weiboUrl, string weiboId) { if (web == null) throw new ArgumentNullException("web"); if (string.IsNullOrEmpty(weiboUrl)) throw new ArgumentNullException("weiboUrl"); if (string.IsNullOrEmpty(weiboId)) throw new ArgumentNullException("weiboId"); web.Encode = Encoding.UTF8; web.Reffer = null; var home = web.GetHTML(weiboUrl); if (string.IsNullOrEmpty(home)) { return string.Format("访问微博{0}页面出错", weiboUrl); } if (home.Contains("<title>404错误</title>")) { return "工作对象被封"; } var location = LocationRegex.Match(home).Groups["location"].Value; if (string.IsNullOrEmpty(location)) { return string.Format("分析微博{0}页面出错", weiboUrl); } var postUrl = string.Format("http://weibo.com/aj/v6/like/add?ajwvr=6"); var postData = string.Format( "version=mini&qid=heart&mid={0}&loc=profile&location={1}", weiboId, location); var postHtml = web.PostWithHeaders(postUrl, postData, new[] { "X-Requested-With: XMLHttpRequest" }); //点赞结果分析 if (string.IsNullOrEmpty(postHtml)) { return "点赞失败,返回空"; } try { dynamic postResult = DynamicJson.Parse(postHtml); return postResult.code == "100000" ? "" : string.Format("点赞失败,{0}", postResult.msg); } catch (Exception) { ComHttpWorkLogger.Info(string.Format("点赞失败\r\n{0}", postHtml)); return "点赞失败,分析失败"; } }
/// <summary> /// 根据微博Url获取微博内容页面 /// </summary> /// <param name="web"></param> /// <param name="url">m.weibo.cn 微博页面</param> /// <returns></returns> public static string GetSingleMblog(WebAccessBase web, string url) { web.Reffer = null; return web.GetHTML(url); }
/// <summary> /// 获取新增粉丝 /// </summary> /// <param name="web"></param> /// <returns></returns> public static string GetNewFans(WebAccessBase web) { web.Reffer = new Uri("http://m.weibo.cn/"); const string url = "http://m.weibo.cn/p/index?containerid=103103"; return web.GetHTML(url); }
/// <summary> /// 收发给自己的私信 /// </summary> /// <param name="web"></param> /// <param name="uid">账号自己的Uid</param> public static List<CnDirectMessagesEntity> RecevieDirectMessages(WebAccessBase web, string uid) { if (web == null) throw new ArgumentNullException("web"); if (string.IsNullOrEmpty(uid)) throw new ArgumentNullException("uid"); List<CnDirectMessagesEntity> result = new List<CnDirectMessagesEntity>(); web.Encode = Encoding.UTF8; web.Reffer = null; var home = web.GetHTML("http://m.weibo.cn/"); if (string.IsNullOrEmpty(home)) { CNHttpWorkLogger.Info("私信{0}访问自己主页为空", uid); return null; } var listStr = web.GetHTML("http://m.weibo.cn/msg/index?format=cards"); try { dynamic listDynamic = DynamicJson.Parse(listStr); var list = listDynamic[0].card_group; foreach (var item in list) { if (!item.IsDefined("text")) continue; if (string.IsNullOrEmpty(item.text)) continue; if (!item.IsDefined("unread") || item.unread == "0") continue; var sendUid = item.user.id; CnDirectMessagesEntity cnDirectMessagesEntity = new CnDirectMessagesEntity { Time = CommonExtension.AnalyseTime(item.created_at), Text = item.text, Uid = sendUid, Nickname = item.user.screen_name }; if (CheckSendUser(web, sendUid)) { result.Add(cnDirectMessagesEntity); } } } catch (Exception ex) { CNHttpWorkLogger.Error(string.Format("{0}分析私信列表失败\r\n{1}", uid, listStr), ex); } web.Reffer = new Uri("http://m.weibo.cn/msg/notes"); var listStr2 = web.GetHTML("http://m.weibo.cn/msg/noteList?page=1"); try { dynamic listDynamic = DynamicJson.Parse(listStr2); if (listDynamic.ok == "1") { var list = listDynamic.data; foreach (var item in list) { CnDirectMessagesEntity cnDirectMessagesEntity = new CnDirectMessagesEntity { Time = CommonExtension.AnalyseTime(item.Value.time), Text = item.Value.text, Uid = item.Value.sender.uid, Nickname = item.Value.sender.name }; result.Add(cnDirectMessagesEntity); } } } catch (Exception ex) { CNHttpWorkLogger.Error(string.Format("{0}分析未关注联系人私信列表失败\r\n{1}", uid, listStr), ex); } return result.OrderByDescending(p => p.Time).ToList(); }
//weibo.com解封 public string Run(WebAccessBase web) { try { web.Reffer = null; string html1 = web.GetHTML("http://weibo.com/"); if (!string.IsNullOrEmpty(html1) && html1.Contains("您当前使用的账号存在异常,请完成以下操作解除异常状态")) { #region 发短信解封 for (int m = 0; m < 10; m++) { string mobile = ""; try { mobile = smsapi.GetMobile(weibo_send_type); if (string.IsNullOrEmpty(mobile)) { //File.AppendAllText("mobile获取为空.txt", DateTime.Now + Environment.NewLine); Thread.Sleep(2000); continue; } //提交手机号到新浪 var url = "http://sass.weibo.com/aj/upside/nextstep?__rnd=" + CommonExtension.GetTime(); var postData = string.Format("mobile={0}&zone=0086&_t=0", mobile); web.Reffer = new Uri("http://sass.weibo.com/unfreeze"); var html = web.PostWithHeaders(url, postData, new[] { "X-Requested-With: XMLHttpRequest" }); if (string.IsNullOrEmpty(html)) continue; var temp1 = DynamicJson.Parse(html); if (temp1.code == "1000") { //发短信 html = smsapi.SendSms(mobile, weibo_send_type, "26"); if (html != "succ") { //File.AppendAllText("SendSms失败.txt", DateTime.Now + "\t" + html + "\t" + mobile + Environment.NewLine); //发生失败后,拉黑手机号,重做 //_smsapi.AddIgnoreList(mobile, _send_type); //Thread.Sleep(1000); continue; } // 收发送结果 string result = ""; int i1 = 0; while (i1 < 10) { result = smsapi.GetSmsStatus(mobile, weibo_send_type); if (result == "succ") break; Thread.Sleep(3000); i1++; } if (i1 >= 10) { //File.AppendAllText("一码收短信超时.txt", DateTime.Now + "\t" + mobile + Environment.NewLine); continue; } if (result == "succ") { //这里要循环检查 for (int i = 0; i < 10; i++) { Thread.Sleep(1000 * 6); url = "http://sass.weibo.com/aj/upside/check?__rnd=" + CommonExtension.GetTime(); postData = string.Format("mobile={0}&_t=0", mobile); web.Reffer = new Uri("http://sass.weibo.com/unfreeze"); html = web.PostWithHeaders(url, postData, new[] { "X-Requested-With: XMLHttpRequest" }); if (html == "{\"code\":\"1000\"}") { //成功处理 web.Reffer = new Uri("http://sass.weibo.com/unfreeze"); web.GetHTML("http://sass.weibo.com/unfreeze?step=2"); return "发短信解封成功"; } } //File.AppendAllText("发短信后检查超时.txt", DateTime.Now + "\t" + html + "\t" + mobile + Environment.NewLine); return "发短信后检查超时"; } } string message = temp1.msg; if (message.Contains("您的账号验证过于频繁") || message.Contains("系统繁忙,请稍候再试吧")) return message; if (message.Contains("换个号码吧")) { Thread.Sleep(3000); } } catch (RuntimeBinderException) { } catch (Exception err) { return err.Message; //File.AppendAllText("UnfreezeRunErr.txt", err + Environment.NewLine); } finally { if (!string.IsNullOrEmpty(mobile)) smsapi.AddIgnoreList(mobile, weibo_send_type); } } #endregion } else { #region 收短信解封 for (int i = 0; i < 30; i++) { string mobile = ""; try { mobile = smsapi.GetMobile(weibo_receive_type); if (mobile == "获取手机号失败") return "获取手机号失败"; string url1 = "http://sass.weibo.com/aj/mobile/unfreeze?__rnd=" + CommonExtension.GetTime(); string post1 = string.Format("value={0}&zone=0086&_t=0", mobile); web.Reffer = new Uri("http://sass.weibo.com/aj/quickdefreeze/mobile"); html1 = web.PostWithHeaders(url1, post1, new[] { "x-requested-with: XMLHttpRequest" }); if (string.IsNullOrEmpty(html1)) continue; var objectError = DynamicJson.Parse(html1); string message = objectError.msg; if (message.Contains("您的账号验证过于频繁") || message.Contains("系统繁忙,请稍候再试吧")) return message; else if (message.Contains("输入的手机号码")) continue; else { int count = 0;//循环计数 string verified = ""; while (verified.Length != 6)//收激活码 { if (count > 10 || verified.Contains("获取验证码失败"))//工作1分钟后退出 break; Thread.Sleep(5000); verified = smsapi.Unlock(mobile, weibo_receive_type); count++; } if (verified.Length == 6) { string url2 = "http://sass.weibo.com/aj/user/checkstatus?__rnd=" + CommonExtension.GetTime(); string post2 = string.Format("code={0}&_t=0", verified); web.Reffer = new Uri("http://sass.weibo.com/aj/quickdefreeze/mobile"); string html2 = web.PostWithHeaders(url2, post2, new string[] { "x-requested-with: XMLHttpRequest" }); if (!string.IsNullOrEmpty(html2) && html2.Contains("100000")) return "解封成功"; else { //File.AppendAllText("解封失败.txt", "收短信" + html2 + "\t" + mobile + "\t" + verified + Environment.NewLine); return "解封失败"; } } } } catch (RuntimeBinderException) { } catch (Exception err) { return err.Message; //File.AppendAllText("UnfreezeRunErr.txt", err + Environment.NewLine); } finally { if (!string.IsNullOrEmpty(mobile)) smsapi.AddIgnoreList(mobile, weibo_receive_type); } } #endregion } } catch (Exception e) { throw e; } return "解封超时"; }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="web"></param> /// <param name="uid"></param> /// <returns></returns> public static CommonEntityLib.Entities.user.Entity GetUserEntity(WebAccessBase web, string uid) { try { var homeStr = GetCnPage.GetUser(web, uid); var result = AnalyseCnPage.AnalysisUserHome(homeStr); return result; } catch (Exception exception) { CNHttpWorkLogger.Error(string.Format("获取用户{0}主页发生异常", uid), exception); return null; } }
/// <summary> /// 收发给自己的评论 /// </summary> /// <param name="web"></param> /// <param name="uid"></param> /// <returns></returns> public static List<Entity> ReceiveComment(WebAccessBase web, string uid) { if (web == null) throw new ArgumentNullException("web"); if (string.IsNullOrEmpty(uid)) throw new ArgumentNullException("uid"); List<Entity> result = new List<Entity>(); web.Encode = Encoding.UTF8; web.Reffer = null; var home = web.GetHTML("http://m.weibo.cn/"); if (string.IsNullOrEmpty(home)) { CNHttpWorkLogger.Info("用户{0}获取自己主页为空", uid); return null; } var allPlStr = web.GetHTML("http://m.weibo.cn/msg/cmts?subtype=allPL"); if (string.IsNullOrEmpty(home)) { CNHttpWorkLogger.Info("用户{0}获取自己评论页为空", uid); return null; } try { string jsonStr = GetHomeCommentJsonStr(allPlStr); dynamic json = DynamicJson.Parse(jsonStr); foreach (var item in json.card_group) { if (string.IsNullOrEmpty(item.text)) continue; var text = item.text; text = HtmlRegex.Replace(text, ""); if (string.IsNullOrEmpty(text)) continue; Entity cnCommentEntity = new Entity { MID = item.card.page_id, //Url = item.card.page_url, CreatedAt = CommonExtension.AnalyseTime(item.created_at).ToString(), ID = item.id, //Cid -->ID Text = text, User = new CommonEntityLib.Entities.user.Entity { ID = item.user.id, ScreenName = item.user.screen_name } //Uid = item.user.id, //Name = item.user.screen_name, //Time = item.created_at.AnalyseTime() }; result.Add(cnCommentEntity); } } catch (Exception ex) { CNHttpWorkLogger.Error(string.Format("{0}分析评论列表失败\r\n{1}", uid, allPlStr), ex); } return result.OrderByDescending(p => DateTime.Parse(p.CreatedAt)).ToList(); }
/// <summary> /// 根据微博Url获取微博内容页面 /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetSingleMblog(string url) { WebAccessBase web = new WebAccessBase { TimeOut = 30000, Reffer = null }; return web.GetHTML(url); }
/* * 爬取用户信息 * 输入uid,输入用户信息 * 作为爬博文的依据 * * 爬取uid的一页博文 * 输入是uid,page,输出是文本 * 输入一个cookies后,自己new爬虫 * reffer使用http://m.weibo.cn/u/uid * * 爬虫博文的一页评论 * 输入是uid,mid,page,输出是文本 * 输入一个cookies后,自己new爬虫 * reffer使用http://m.weibo.cn/uid/mid */ /// <summary> /// 获取用户主页的信息 /// </summary> /// <param name="uid"></param> /// <returns></returns> public static string GetWeiboUser(string uid) { WebAccessBase web = new WebAccessBase { TimeOut = 30000, Reffer = null }; //获取主页 var url = string.Format("http://m.weibo.cn/u/{0}", uid); return web.GetHTML(url); }
/// <summary> /// 发表微博 /// </summary> /// <param name="web"></param> /// <param name="text">需要发布的文本内容</param> /// <param name="pic"></param> /// <param name="appkey"></param> /// <returns></returns> public static string AddMblog(WebAccessBase web, string text, string pic = null, string appkey = null) { if (web == null) { throw new ArgumentNullException("web"); } if (string.IsNullOrEmpty(text)) { throw new ArgumentNullException("text", "微博内容不能为空"); } web.Encode = Encoding.UTF8; web.Reffer = new Uri("http://weibo.com/"); var url = string.Format("http://weibo.com/aj/mblog/add?ajwvr=6&__rnd={0}", CommonExtension.GetTime()); var postData = string.Format( "location=v6_content_home&appkey={2}&style_type=1&pic_id={1}&text={0}&pdetail=&rank=0&rankid=&module=stissue&pub_type=dialog&_t=0", text, pic, appkey); var htmlMsg = web.PostWithHeaders(url, postData, new[] { "X-Requested-With: XMLHttpRequest" }); if (!string.IsNullOrEmpty(htmlMsg) && htmlMsg.Contains("\"code\":\"100000\"")) { return ""; } ComHttpWorkLogger.Info(string.Format("发微博失败\r\n{0}", htmlMsg)); return string.Format("发微博失败"); }
public List<CommonEntityLib.Entities.status.Entity> GetMblogs(WebAccessBase web, string uid, string mid, int page) { throw new NotImplementedException(); }
/// <summary> /// 删除微博 /// </summary> /// <param name="web"></param> /// <param name="url"></param> /// <param name="mid"></param> /// <returns></returns> public static string DelMblog(WebAccessBase web, string url, string mid) { web.Reffer = new Uri("http://weibo.com/"); var weiboStr = web.GetHTML(url); if (string.IsNullOrEmpty(weiboStr)) { ComHttpWorkLogger.Info("访问微博{0}页面出错", url); return "网络错误 删除微博"; } if (weiboStr.Contains("<script>parent.window.location=\"http://weibo.com/sorry?pagenotfound\"</script>")) { return "微博不存在"; } const string posturl = "http://weibo.com/aj/mblog/del?ajwvr=6"; var postData = "mid=" + mid; var htmlMsg = web.PostWithHeaders(posturl, postData, new[] { "X-Requested-With: XMLHttpRequest" }); if (!string.IsNullOrEmpty(htmlMsg) && htmlMsg.Contains("\"code\":\"100000\"")) { return ""; } ComHttpWorkLogger.Info(string.Format("删除微博失败\r\n{0}", htmlMsg)); return string.Format("删除微博失败"); }
/// <summary> /// 收取邮箱验证码 /// </summary> /// <param name="email">邮箱</param> /// <returns>验证码(未收到:收取验证码失败)</returns> private static string GetDoor(string email) { var web2 = new WebAccessBase { TimeOut = 90000 }; var door = web2.GetHTML("http://222.185.251.62:55888/getcaptchaweb2/getcaptcha.aspx?key=2EC944F05E0044E7B29F222ECBF62EC0&email=" + email); if (string.IsNullOrEmpty(door) || door == "未找到验证码邮件") door = "收取验证码失败"; return door; }
/// <summary> /// 获取指定页码的微博 /// 遇到指定的mid则不再查找 /// </summary> /// <param name="web"></param> /// <param name="uid">被查找的uid</param> /// <param name="mid">小于该指定的mid不再查找</param> /// <param name="page">查找页数</param> /// <returns></returns> public List<CommonEntityLib.Entities.status.Entity> GetMblogs(WebAccessBase web, string uid, string mid, int page) { ComHttpWorkLogger.Warn("Com 未实现GetMblogs web uid mid page"); return new List<CommonEntityLib.Entities.status.Entity>(); }
/// <summary> /// 解锁新浪微博账号 /// </summary> /// <param name="web">已登录新浪微博HTTP操作对象</param> /// <param name="email">解锁邮箱</param> /// <param name="oldpassword">账号原始密码</param> /// <returns>账号解锁成功后新密码</returns> public static string Run(WebAccessBase web, string email, string oldpassword) { //记录是否从手机页面转到邮箱页面 var ischangepage = false; var changepageurl = ""; var newpassword = GenerateNewPassword.GetNewPassword(oldpassword); web.Encode = Encoding.GetEncoding("gb2312");//操作的所有页面都使用gb2312编码 //解锁页面 var html = web.GetHTML(TestifyUrl); if (string.IsNullOrEmpty(html)) return "网络错误,解锁失败"; if (!html.Contains("安全邮箱")) return "没有安全邮箱,无法通过邮箱解锁失败"; if (!html.Contains("确认安全邮箱")) { ischangepage = true; //将页面跳转至邮箱找回页面 web.Reffer = new Uri(TestifyUrl); changepageurl = "http://login.sina.com.cn/member/testify/testify.php?" + GenerateChangePageData(html); html = web.GetHTML(changepageurl); //return "不是安全邮箱页面,无法通过邮箱解锁失败"; } //发验证码 var sendcodePostData = GenerateUnlockPostData(html, email); const string sendcodePostUrl = "http://login.sina.com.cn/member/testify/testify_sendcode.php"; var tempHtml = web.PostWithHeaders(sendcodePostUrl, sendcodePostData, new[] { "X-Requested-With: XMLHttpRequest" }); if (string.IsNullOrEmpty(tempHtml) || !tempHtml.Contains("100000")) { //File.AppendAllText(System.Environment.CurrentDirectory + "/解锁错误html.txt", DateTime.Now + " " + tempHtml + Environment.NewLine); return "页面发送邮箱验证码失败"; } //接受验证码 var door = GetDoor(email); if (door == "收取验证码失败") return "收取验证码失败"; //验证邮箱 var allPostData = GenerateUnlockPostData(html, email, door); const string allPostUrl = "http://login.sina.com.cn/member/testify/testify_all.php"; web.Reffer = !ischangepage ? new Uri(TestifyUrl) : new Uri(changepageurl); tempHtml = web.PostWithHeaders(allPostUrl, allPostData, new[] { "X-Requested-With: XMLHttpRequest" }); if (string.IsNullOrEmpty(tempHtml) || !tempHtml.Contains("100000")) return "验证邮箱失败"; //GET修改密码页面 web.Reffer = !ischangepage ? new Uri(TestifyUrl) : new Uri(changepageurl); web.GetHTML("http://login.sina.com.cn/member/security/password.php?entry=weibo&testified=succ"); var ajPasswordPostData = GenerateChangePasswordPostData(oldpassword, newpassword); //File.AppendAllText("testifyPasswordPost.txt", ajPasswordPostData + Environment.NewLine); if (ajPasswordPostData == "密码数据生成失败") return "密码数据生成失败"; const string ajPasswordPostUrl = "http://login.sina.com.cn/member/security/aj_password.php"; tempHtml = web.PostWithHeaders(ajPasswordPostUrl, ajPasswordPostData, new[] { "X-Requested-With: XMLHttpRequest" }); if (string.IsNullOrEmpty(tempHtml)) return "修改失败"; //File.AppendAllText("testifyHtml.txt", tempHtml + Environment.NewLine); try { var result = DynamicJson.Parse(tempHtml); if (result.status == "1") return newpassword; } catch { } return "修改失败"; }