本帖最后由 cload 于 2017-12-2 23:04 编辑
将https://www.west.cn/services/dom ... tok&_=1512221607475类似链接返回的内容传递进去,生成这个Cookie。
[C#] 纯文本查看 复制代码 [i][i][i][i][i] #region 计算qtoken2016
[/i][/i][/i][/i][/i][i][i][i][i][i] private static string Getqtoken2016(string source)
{
string cookie = "qtoken2016=";
List<string> BaseStr = new List<string>();
List<string> Serial = new List<string>();
source = Utilities.GetMidStr(source, "=[", "]");
string[] num = source.Split(',');
for (int i = 0; i < num.Length; i++)
{
if (BaseStr.Count == 0 && num[i] == "92")
{
for (int j = i + 1; j < num.Length; j++)
{
if (num[j] == "94")
{
i = j + 1;
break;
}
BaseStr.Add(num[j]);
}
}
else if (Serial.Count == 0 && num[i] == "92")
{
for (int j = i + 1; j < num.Length; j++)
{
if (num[j] == "94") break;
Serial.Add(num[j]);
}
}
}
BaseStr = List2Str(BaseStr);
Serial = List2Str(Serial);
for (int i = 0; i < Serial.Count; i++)
{
cookie += Ascii2Str(BaseStr[Convert.ToInt16(Serial[i])]);
}
return cookie;
}
private static List<string> List2Str(List<string> BaseStr)
{
List<string> str1 = new List<string>();
string tem = "";
for (int i = 0; i < BaseStr.Count; i++)
{
if (BaseStr[i] == "45")
{
str1.Add(tem);
tem = "";
}
else
{
tem += Ascii2Str(BaseStr[i], true);
}
if (i == BaseStr.Count - 1) str1.Add(tem);
}
return str1;
}
private static string Ascii2Str(string ascii, bool sub = false)
{
int m = 0;
byte[] buf = new byte[1];
if (sub) m = 1;
buf[0] = (byte)(Convert.ToInt16(ascii) - m);
return Convert.ToString(Encoding.ASCII.GetString(buf));
}
[/i][/i][/i][/i][/i][i][i][i][i][i] #endregion
[/i][/i][/i][/i][/i][i][i][i][i][i] |