您的位置:首页 > 编程语言 > C#

[C#源代码]QQ空间日志刷人气代码

2013-09-02 11:29 246 查看
这个代码好像上传不了资源,会被删,所以还是写在这里吧。其实很简单,刷日志人气和说说刷赞刷评论不同,刷日志流量不需要登录QQ号,只需要不断向一个指定网址发送HTTP请求就可以了。

首先定义一个日志结构体

/*定义日志结构体*/
struct stBlogs
{
public  string strBID;//ID号
public string strName;//日志名
public string strPv;//当前阅读量

}


构造访问的地址

string StrURL_Template = "http://183.62.121.21:80/cgi-bin/blognew/blog_output_titlelist?uin={0}&vuin=0&property=GoRE&getall=1&styledm=ctc.qzonestyle.gtimg.cn&imgdm=ctc.qzs.qq.com&bdm=b.qzone.qq.com&category=&num=15&sorttype=0&arch=0&from=0&maxlen=68&v=1.";
string strURLPRTemplate = "http://183.62.121.21/cgi-bin/blognew/blog_get_countlist?type=1&uin={0}&blogids={1}";
string strURLFinalTemplate = "http://183.62.121.21/cgi-bin/blognew/blog_get_data?uin={0}&num=15&blogid={1}&from=0&type=2.";
string strURL1 = string.Format(StrURL_Template, strQQ);
string strQBlogContent = MyHttp.GetHtml(strURL1); //这个MyHttp.GetHtml是一个用来构造HTTP访问的静态函数


这里就获取到了日志列表的xml信息。

接着通过正则匹配获取到指定节点内容,即日志信息如日志id号等 这里用到了HtmlAgilityPack这个库,至于它的用法,可以自行百度一下。就不赘述了。

//正则匹配
//HtmlWeb hw = new HtmlWeb();
HtmlAgilityPack.HtmlDocument hdoc_DownPage = new HtmlAgilityPack.HtmlDocument();
hdoc_DownPage.LoadHtml(strQBlogContent);
//获取 Ul下面的li
//获取指定的节点
HtmlNode node = hdoc_DownPage.DocumentNode.SelectSingleNode("./ul[1]");
if (node == null)
{
MessageBox.Show("未找到节点");
return;
}
//遍历每一个子节点的 li
for (int i = 0; i < node.ChildNodes.Count;i++ )
{
HtmlNode childNode = node.ChildNodes[i];
if (childNode.Name != "li")
{
continue;
}

//blog id 号码
string strBID = null;
string strBName = null;

//实际上每个li节点返回的只有一个 bid
ArrayList ArryID = getLabelVal(hdoc_DownPage,childNode.XPath,"input","bid");
if (ArryID.Count == 0)
return;

//匹配的正则表达式  匹配数字的bid
Regex r = new Regex(@"\d[\d]*");
//开始匹配
Match m = r.Match(ArryID[0].ToString());
while (m.Success)
{
//匹配成功  获得日志的id号码
strBID =  m.Groups[0].Value;

//从上一个匹配结束的位置开始下一个匹配
m = m.NextMatch();
}

//返回日志名称   这次会返回四个 title 取得第一个title当日志名字就可以了
ArrayList ArryBlogNames = getLabelVal(hdoc_DownPage, childNode.XPath, "span", "title");
if(ArryBlogNames.Count == 0)
{
MessageBox.Show("获取日志名称失败!");
return;
}
Regex r2 = new Regex(@"[^\\""][^\\]*");
//开始匹配
Match m2 = r2.Match(ArryBlogNames[0].ToString());
while (m2.Success)
{
//匹配成功  获得日志的名字
strBName = m2.Groups[0].Value;

//从上一个匹配结束的位置开始下一个匹配
m2 = m2.NextMatch();
}

//获取阅读数
//访问 http://183.62.121.21/cgi-bin/blognew/blog_get_countlist?type=1&uin=123456789&blogids=1354896011 string strURLReadPG = string.Format(strURLPRTemplate, strQQ, strBID);
string strReadPage = MyHttp.GetHtml(strURLReadPG);

/*   strReadPage的内容如下 这里 read 后面的内容就是阅读量
* _Callback(
{"data":{
"type":1,
"itemlist":[{"id":1354896011,
"reply":"-",
"read":300}]
}}
*/
string strQBlogPv = null;
Regex r3 = new Regex(@"read\"":\d.*\d\b");
//开始匹配
Match m3 = r3.Match(strReadPage);
while (m3.Success)
{
//匹配成功  获得日志流量量  read":300
strQBlogPv = m3.Groups[0].Value;

//取得其中的数字
strQBlogPv = strQBlogPv.Replace("read\":","");

//从上一个匹配结束的位置开始下一个匹配
m3 = m3.NextMatch();
}

//这里获取到了id和名字
stBlogs sbs = new stBlogs();
sbs.strBID  = strBID;
sbs.strName = strBName;
sbs.strPv = strQBlogPv;
//添加到列表中
list_Blog.Add(sbs);
}

this.BeginInvoke(mi, new Object[] {});

}


在获取到日志的id,也就是bid,之后就可以构造一个类似于

"http://183.62.121.21/cgi-bin/blognew/blog_get_data?uin={0}&num=15&blogid={1}&from=0&type=2.


这种地址进行访问,就可以让指定的日志访问量增加。当然,这个Bug不知道是否已经被腾讯修复,新手可以参考一下这个思路。

string strPage2Refresh = string.Format(strURLFinalTemplate, strQQ, list_Blog[i].strBID);


MyHttp.GetHtml(strPage2Refresh);


/*****************************************Witch_Soya***********************************/
/****************************************2013年9月2日11:28:23***********************/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: