樂斗獲取好友信息十分簡單,只需要攜帶cookie訪問 http://fight.pet.qq.com/cgi-bin/petpk?cmd=view&kind=1&sub=1就可以了
比較難的是分析個(gè)參數(shù)的意義,需要多個(gè)好友相互對(duì)比
服務(wù)器返回如下:
{result:'0',msg:'',info:[{uin:'xxxxxxxx',flag:'0',yflag:'0',qqflag:'0',name:'樂斗菜菜', lilian:'19',enable:'1', factionid:'0'},{uin:'xxxxxxxx',flag:'0',yflag:'0',qqflag:'0',name:'樂斗小王子', lilian:'37',enable:'2', factionid:'10007'},{uin:'xxxxxxxx',flag:'0',yflag:'0',qqflag:'2',name:'Going_Down', lilian:'32',enable:'1', factionid:'235884'},................
其中uin為好友的QQ號(hào)碼 ,flag沒去研究 yflag為會(huì)員黃鉆等信息 name為網(wǎng)名 lilian為等級(jí) enable為0則已經(jīng)和他打斗過 1 沒有打斗過 2他有拳套,沒有打斗過
factionid為幫派ID
給出代碼:
獲取好友
public Dictionary<string,QchongEntity> getAllFriend(){
Dictionary<string,QchongEntity> entitys =new Dictionary<string,QchongEntity>();
HttpHelper.Encoding = Encoding.GetEncoding("gb2312");
string result = HttpHelper.GetHtml("http://fight.pet.qq.com/cgi-bin/petpk?cmd=view&kind=1&sub=1", user.Cookie);
result = result.Replace("", "");
if (result !="")
{
//歷練導(dǎo)致少取到5個(gè)號(hào)碼
Regex r =new Regex("(uin:')(?<qq>[0-9]{5,11}?)(',flag:'[0-9]{1}',yflag:'[0-9]{1}',qqflag:')(?<qqflag>[0-9]{1}?)(',name:')"
+"(?<name>.+?)(',lilian:')(?<lilian>[0-9]{1,2}?)(',enable:')(?<enable>[0-9]{1}?)(',factionid:')(?<factionid>[0-9]{1,6}?)(')", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
MatchCollection m = r.Matches(result);
for (int i =0; i < m.Count; i++)
{
try
{
QchongEntity entity =new QchongEntity();
entity.UserName = m[i].Groups["qq"].Value;
entity.Qqflag = Convert.ToInt32(m[i].Groups["qqflag"].Value);
entity.NickName = m[i].Groups["name"].Value;
entity.Liliang = m[i].Groups["lilian"].Value;
entity.Factionid = m[i].Groups["factionid"].Value;
entity.Enable = Convert.ToInt32(m[i].Groups["enable"].Value);
entitys.Add(entity.UserName,entity);
}
catch (Exception)
{
continue;
}
}
}
AllFriend = entitys;
return entitys;
}