public BaseUser getUserInfo(params string[] args) { #region request url StringBuilder builder = new StringBuilder(); builder.Append(API_SER).Append(USER_INFO).Append("?access_token=").Append(mToken); if (args.Length > 0 && args[0] != null) { builder.Append("&uid=").Append(args[0]); } if (args.Length > 1 && args[1] != null) { builder.Append("&screen_name=").Append(args[1]); } #endregion #region response BaseUser user = null; try { string json = mRequest.GetData(builder.ToString()); var jnode = JSON.Parse(json); user = new BaseUser(); user.UserId = jnode["id"]; user.UserName = jnode["screen_name"]; user.UserHeaderUri = jnode["profile_image_url"]; } catch (Exception) {} #endregion return(user); }
public void TakeData(BaseData[] takeWeibos, BaseUser user) { Count++; if (ifLog && Count == 1 && takeLoger != null) { takeLoger.log(format(takeWeibos)); } if (shower != null) { shower.showResult(String.Format("第{0}次,{1}条", Count, takeWeibos.Length), format(takeWeibos)); } }
/// <summary> /// 整页html提取用户信息,头像,昵称 /// </summary> /// <param name="html"></param> public override BaseUser paserUser(String html) { Match mathe = mUserReg.Match(html); if (mathe.Success) { User = new BaseUser(); User.UserId = Uid; User.UserHeaderUri = mathe.Groups[mUserImgGroups].Value.Replace("\\", "").Replace("400x400", "normal"); User.UserName = mathe.Groups[mUserNameGroups].Value.Replace("\\", ""); User.Source = getTakerName(); } return(User); }
public override BaseUser paserUser(String html) { Match mathe = mWeiboUserReg.Match(html); if (mathe.Success) { User = new BaseUser(); User.UserId = Uid; User.UserHeaderUri = mathe.Groups[mWeiboUserImgGroups].Value.Replace("\\", ""); User.UserHeaderUri = mWeiboImageCropReg.Replace(User.UserHeaderUri, "${1}" + "20"); User.UserName = mathe.Groups[mWeiboUserNameGroups].Value.Replace("\\", ""); User.Source = getTakerName(); } return(User); }
public virtual void downloadUserHeader(BaseUser user) { if (user != null) { if (user.UserHeader == null) { string path = ImageHelper.download(wb, user.UserHeaderUri); if (path != null) { try { user.UserHeader = Image.FromFile(path); user.UserHeader = ImageHelper.changeSize(user.UserHeader, 20, 20); } catch (Exception) { File.Delete(path); } } } } }
public void NewData(BaseData[] newWeibos, BaseData[] all, BaseUser user) { string userName = null; Image userHeader = null; string source = null; if (user != null) { if (showHeader) { userName = user.UserName; userHeader = user.UserHeader; } if (showFooter) { source = "本信息来自[" + user.Source + "] "; } } if (newWeibos.Length > 5) { Exception e = new Exception(string.Format("{0}条新数据,超过5条新数据,可能存在对比异常", newWeibos.Length)); string text = format(e); shower.showResult(String.Format("第{0}次,{1}条", Count, newWeibos.Length), text); takeLoger.log(text); } else { foreach (BaseData weibo in newWeibos) { string newFooter = source + (weibo.TimeStamp == null ? "" : weibo.TimeStamp); Image longImage = null; BaseData useWeibo = weibo; if (weibo != null && weibo.Taker != null) { useWeibo = weibo.Taker.onUse(weibo); longImage = weibo.Taker.makeLongImage(weibo); } Image[] sendImgs; if (longImage == null) { sendImgs = new Image[0]; } else { sendImgs = new Image[1]; sendImgs[0] = longImage; } if (senders != null && senders.Count > 0) { sendCount += 1;// senders.Count; foreach (Sender sender in senders) { sender.sendWithUser(userName, userHeader, newFooter, useWeibo.Text, sendImgs, useWeibo.LongImgPath); } shower.showCount("已发送:" + sendCount); } if (ifLog && loger != null) { loger.log(useWeibo); } } } if (newWeibos != null && newWeibos.Length > 0) { if (ifLog && takeLoger != null) { takeLoger.log(format(all)); } } else { if (ifLog && takeLoger != null && Count != 1) { takeLoger.log(formatNoChange()); } } }