软件编程
位置:首页>> 软件编程>> C#编程>> 利用C#快速查出哪些QQ好友空间屏蔽了自己

利用C#快速查出哪些QQ好友空间屏蔽了自己

作者:一只想飞的小蚂蚁  发布时间:2023-10-07 22:14:28 

标签:C#,QQ,屏蔽

大家好,我叫柠檬水,今天马上就要放假,突然想到自己以前的伙伴、同学,好像想到他们空间没怎么发过动态,难道是把我屏蔽了吗,好友又那么多,行吧,只能用c#写一个快速的知道哪些人屏蔽了自己。

首先我们整理逻辑,我们需要所有好友的QQ号,然后是一个通过qq号知道这个人是否空间屏蔽了自己的接口

qq号我倒是想到了腾讯官方提供的qq群里的某一个接口,后面的嘛,可以通过访问qq空间的那个接口嘛,嘿嘿,我真是太机智了 竟然我们逻辑都已经想好了,那么后面的事情就简单多了

利用C#快速查出哪些QQ好友空间屏蔽了自己

首先我们进入qq群

利用C#快速查出哪些QQ好友空间屏蔽了自己

进去后我们可以看到不仅是所有的QQ群有,连当前qq的所有好友也有 我们点击好友那个接口,打开所有的好友,直接复制就行了,其它的交给正则表达式吧!

然后我们登录QQ号,打开这个链接 http://user.qzone.qq.com/自己QQ号/infocenter 打开f12,刷新找到第一个接口,找到发送请求的cookie,现在c#获取cookie我还不会哦,写爬虫还是python好呢

现在我们有三个准备了,登录状态下的QQ号,cookie已经所以的qq好友 接下来看我的完整代码

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApp6
{
   class Program
   {
       static void Main(string[] args)
       {

string url = "http://user.qzone.qq.com/<<QQ>>/infocenter";

string txt = "";
           StreamReader sr = new StreamReader(@"qq.txt");//里面装的是所以qq好友,直接将复制的写进去
           while (!sr.EndOfStream)
           {
               string str = sr.ReadLine();
               txt += str + "\n";
           }
           sr.Close();
           string regex1 = "name: \"(?<name>.*?)\",";//获取QQ昵称
           string regex2 = "uin: (?<qq>.*?)}";//获取QQ昵称

MatchCollection namelist = Regex.Matches(txt, regex1);
           MatchCollection qqlist = Regex.Matches(txt, regex2);
           if (namelist.Count != qqlist.Count)
           {
               Console.WriteLine("qq昵称与QQ号数目不匹配!");
               return;
           }

Dictionary<string, string> dic = new Dictionary<string, string>();

for (int i = 0; i < namelist.Count; i++)
           {
               string qqname = Regex.Match(namelist[i].Value, regex1).Groups["name"].ToString().Trim();
               string qqnumber = Regex.Match(qqlist[i].Value, regex2).Groups["qq"].ToString().Trim();
               dic.Add(qqname, qqnumber);
           }

string cookie = "#";//将复制的cookie放在里面哦

foreach (var item in dic)
           {
               url = url.Replace("<<QQ>>", item.Value);
               HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
               req.Method = "GET";
               req.Accept = "text/html";
               req.AllowAutoRedirect = true;
               req.Headers.Add("Encoding", Encoding.UTF8.ToString());
               req.Headers.Add("cookie", cookie);
               req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36";
               HttpWebResponse res = (HttpWebResponse)req.GetResponse();
               using (StreamReader reader = new StreamReader(res.GetResponseStream()))
               {
                   string html = reader.ReadToEnd();
                   if (!string.IsNullOrEmpty(html))
                   {
                       string filePath = System.IO.Directory.GetCurrentDirectory() + "\\" + item.Key + item.Value + ".txt";
                       using (StreamWriter sw = new StreamWriter(filePath))
                       {
                           sw.Write(html);
                       }
                       Console.WriteLine(item.Key + item.Value +"Download OK!\n");
                   }

}
               url = url.Replace(item.Value,"<<QQ>>");
           }
           Console.WriteLine("成功啦,去程序目录一个个看吧!");
       }
   }
}

里面有说放qq号和cookie的注释,然后运行

利用C#快速查出哪些QQ好友空间屏蔽了自己

利用C#快速查出哪些QQ好友空间屏蔽了自己

如果里面有这句话的,唉

利用C#快速查出哪些QQ好友空间屏蔽了自己

总体来说,其实可以直接得出结果的,但是,每一个好友难道不值得你一个一个看嘛,如果想用直接得出结果,可以联系我哦,其实后面加个判断就行了!

人生若只如初见,何事秋风悲画扇!

来源:https://blog.csdn.net/qq_44838095/article/details/122807945

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com