29Wx状态初始化

This commit is contained in:
wule committed 2026-06-11 15:17:50 +08:00
1 parent 9fd5579fcd
commit 40c702883c
322 files changed
+155553

No files matched your search

+158
View File
@@ -0,0 +1,158 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Work.Pinduoduo
{
public class DataOpenSSL
{
public static byte[] key = new byte[32] { 145, 232, 156, 201, 201, 0, 42, 184, 222, 111, 109, 49, 226, 169, 9, 44, 151, 148, 143, 120, 62, 84, 30, 170, 127, 242, 20, 141, 231, 33, 230, 6 };
public static byte[] iv = new byte[16] { 113, 6, 75, 177, 160, 112, 73, 39, 178, 147, 82, 107, 186, 58, 144, 187 };
/// <summary>
/// 加密
/// </summary>
/// <param name="plainText"></param>
/// <returns></returns>
public static string EncryptString(string plainText)
{
try
{
// Instantiate a new Aes object to perform string symmetric encryption
Aes encryptor = Aes.Create();
encryptor.Mode = CipherMode.CBC;
// Set key and IV
byte[] aesKey = new byte[32];
Array.Copy(key, 0, aesKey, 0, 32);
encryptor.Key = aesKey;
encryptor.IV = iv;
// Instantiate a new MemoryStream object to contain the encrypted bytes
MemoryStream memoryStream = new MemoryStream();
// Instantiate a new encryptor from our Aes object
ICryptoTransform aesEncryptor = encryptor.CreateEncryptor();
// Instantiate a new CryptoStream object to process the data and write it to the
// memory stream
CryptoStream cryptoStream = new CryptoStream(memoryStream, aesEncryptor, CryptoStreamMode.Write);
// Convert the plainText string into a byte array
byte[] plainBytes = Encoding.UTF8.GetBytes(plainText);
// Encrypt the input plaintext string
cryptoStream.Write(plainBytes, 0, plainBytes.Length);
// Complete the encryption process
cryptoStream.FlushFinalBlock();
// Convert the encrypted data from a MemoryStream to a byte array
byte[] cipherBytes = memoryStream.ToArray();
// Close both the MemoryStream and the CryptoStream
memoryStream.Close();
cryptoStream.Close();
// Convert the encrypted byte array to a base64 encoded string
string cipherText = Convert.ToBase64String(cipherBytes, 0, cipherBytes.Length);
cipherText = cipherText.Replace("+", "-").Replace("/", "_").Replace("=", "");
// Return the encrypted data as a string
return cipherText;
}
catch (Exception)
{
//throw;
}
return plainText;
}
/// <summary>
/// 解密
/// </summary>
/// <param name="cipherText"></param>
/// <returns></returns>
public static string DecryptString(string cipherText)
{
cipherText = cipherText.Replace("-", "+").Replace("_", "/");
var x1 = cipherText.Length % 4;
if (x1 > 0)
{
cipherText = cipherText + "====".Substring(x1);
}
// Instantiate a new Aes object to perform string symmetric encryption
Aes encryptor = Aes.Create();
encryptor.Mode = CipherMode.CBC;
// Set key and IV
byte[] aesKey = new byte[32];
Array.Copy(key, 0, aesKey, 0, 32);
encryptor.Key = aesKey;
encryptor.IV = iv;
// Instantiate a new MemoryStream object to contain the encrypted bytes
MemoryStream memoryStream = new MemoryStream();
// Instantiate a new encryptor from our Aes object
ICryptoTransform aesDecryptor = encryptor.CreateDecryptor();
// Instantiate a new CryptoStream object to process the data and write it to the
// memory stream
CryptoStream cryptoStream = new CryptoStream(memoryStream, aesDecryptor, CryptoStreamMode.Write);
// Will contain decrypted plaintext
string plainText = String.Empty;
try
{
// Convert the ciphertext string into a byte array
byte[] cipherBytes = Convert.FromBase64String(cipherText);
// Decrypt the input ciphertext string
cryptoStream.Write(cipherBytes, 0, cipherBytes.Length);
// Complete the decryption process
cryptoStream.FlushFinalBlock();
// Convert the decrypted data from a MemoryStream to a byte array
byte[] plainBytes = memoryStream.ToArray();
// Convert the decrypted byte array to string
plainText = Encoding.UTF8.GetString(plainBytes, 0, plainBytes.Length);
}
catch (Exception)
{
//throw;
}
finally
{
// Close both the MemoryStream and the CryptoStream
memoryStream.Close();
cryptoStream.Close();
}
// Return the decrypted data as a string
return plainText;
}
}
}
+118
View File
@@ -0,0 +1,118 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.BaseForms;
using Work.Tips;
namespace Work.Pinduoduo
{
public class PddProductDetail
{
#region 通过代理ip获取商品详情
public static string key = "";
public static DateTime endTime = BaseClass.GetServerTimeString();
public static List<SkuDetail> GetProDetails(string id)
{
string url = "";
string html = "";
if (string.IsNullOrEmpty(key) || endTime <= BaseClass.GetServerTimeString())
{
string data = UserLogin.GetSignaturex();
url = BaseClass.BuildObjString("check_vcode&act=get_agent_ip");
html = GetHtml.PostUtf8(url, data);
if (!html.Contains("\"code\":200"))
{
BaseMsgForm.ShowError("请求失败,请过几秒后再试!", "提示", FormLevel.SMALL);
return null;
}
key = BaseRegex.GetStringJson(ref html, "the_key_temp");
var endTimeStr = BaseRegex.GetStringJson(ref html, "end_time");
endTime = Convert.ToDateTime(endTimeStr);
}
url = "http://goods.66daili.cn/api/goods/get/?orderid=" + DataOpenSSL.DecryptString(key) + "&token=5AF433ED506FA475&goodID=" + id;
html = GetHtml.PostUtf8(url, "");
if (html.Contains("req too many"))
{
Thread.Sleep(3000);
html = GetHtml.PostUtf8(url, "");
}
if (html.Contains("\"code\":408"))
{
BaseMsgForm.ShowError("请求频繁,请过几秒后再试!", "提示", FormLevel.SMALL);
return null;
}
html = GetHtml.UrlDecode(html);
return GetSkuArr(html);
}
#endregion
public static List<SkuDetail> GetSkuArr(string html)
{
var skuArr = BaseRegex.GetMatchRegex(ref html, "\"sku_id\":[\\s\\S]+?attribute\":[\\S\\s]+?\"");
List<SkuDetail> skuDetailList = new List<SkuDetail>();
for (int i = 0; i < skuArr.Count; i++)
{
SkuDetail skuDetail = new SkuDetail();
var skuItem = skuArr[i].Value;
string sku_id = BaseRegex.GetStringJson(ref skuItem, "sku_id");
string thumb_url = BaseRegex.GetStringJson(ref skuItem, "thumb_url");
decimal normal_price = BaseRegex.GetDecimalJson(ref skuItem, "normal_price");
decimal group_price = BaseRegex.GetDecimalJson(ref skuItem, "group_price");
var skuSpecArr = BaseRegex.GetMatchRegex(ref skuItem, "(\\{\"spec_key\":[\\s\\S]+?\"spec_value_id\":[\\s\\S]+?\\})");
skuDetail.sku_id = sku_id;
skuDetail.thumb_url = thumb_url;
skuDetail.normal_price = normal_price;
skuDetail.group_price = group_price;
skuDetail.skuSpecs = new List<SkuSpecs>();
for (int j = 0; j < skuSpecArr.Count; j++)
{
SkuSpecs skuSpec = new SkuSpecs();
var specItem = skuSpecArr[j].Value;
string spec_value = BaseRegex.GetStringJson(ref specItem, "spec_value");
skuSpec.spec_value = spec_value;
skuSpec.spec_value = spec_value;
skuDetail.skuSpecs.Add(skuSpec);
}
skuDetailList.Add(skuDetail);
}
return skuDetailList;
}
}
//public class ProductDetail
//{
// public List<SkuDetail> skuDetail { get; set; }
//}
public class SkuDetail
{
public string sku_id { get; set; }
public string thumb_url { get; set; }
public List<SkuSpecs> skuSpecs { get; set; }
public decimal normal_price { get; set; }
public decimal group_price { get; set; }
}
public class SkuSpecs
{
public string spec_value { get; set; }
}
}