zoukankan      html  css  js  c++  java
  • 《小C QQ空间转帖、分享工具》之QQ空间数据传递的g_tk算法(C#)

    原文地址:http://user.qzone.qq.com/419067339/2

    public string GET_HTTP(string url, string referer_post, string accept_post, string useragent_post, bool keepalive, CookieContainer CookieContainer_Post,int i)
    {
    System.Uri httpposturl = new System.Uri(url);
    HttpWebRequest reqp;
    reqp = WebRequest.Create(url) as HttpWebRequest;
    reqp.Method = "GET";
    reqp.Referer = referer_post;
    reqp.Accept = accept_post;
    reqp.UserAgent = useragent_post;
    reqp.CookieContainer = CookieContainer_Post;
    HttpWebResponse resp = reqp.GetResponse() as HttpWebResponse;
    StreamReader reader = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.Default);
    string respHTML = reader.ReadToEnd();
    if (reqp.CookieContainer != null)
    {
    Form1.caozuo.User_Cookies[i] = reqp.CookieContainer;
    string shuju = "";
    foreach (Cookie cookie in resp.Cookies)

    {
    shuju += cookie.Name + "-" + cookie.Value;//获取所有的Cookies值
    }
    string str = shuju.Substring(shuju.IndexOf("skey-") + 5, 10);//提取skey-后面的10个字符用于算出g_tk值
    long hash = 5381;
    for (int o = 0; o < str.Length; o++)
    {
    hash += (hash << 5) + str[o];
    }
    hash = hash & 0x7fffffff;//hash就是算出的g_tk值了.

    Form1.caozuo.临时传递TK值 = hash.ToString();
    }
    resp.Close();
    return respHTML;
    }

    用法:GET_HTTP(URL, 来路, "*/*", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)", false, new CookieContainer(),Cookies编号(因为我使用到了多账号));

  • 相关阅读:
    Linux配置Nginx负载均衡
    linux虚拟机ping不通主机和外网(包括刚装系统遇到的一些问题)
    MySQL的主从复制
    ubuntu下安装php
    ubuntu下sudo apt-get update Sources 404 Not Found 解决方法
    java 中类的加载顺序
    PHP生成各种验证码和Ajax验证
    PHP算法之二分查找和顺序查找
    ThinkPHP中SQL调试方法
    mysql 处理中文乱码问题
  • 原文地址:https://www.cnblogs.com/niaowo/p/3970859.html
Copyright © 2011-2022 走看看