temu客户端程序
This commit is contained in:
commit
4aaf264e89
694 files changed
+263780
No files matched your search
@@ -0,0 +1,833 @@
|
||||
using AllBase;
|
||||
using LittleRabbit.LittleRabbitForms.BaseForms;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Work;
|
||||
using Work.Api;
|
||||
using Work.CollectClass;
|
||||
|
||||
namespace LittleRabbit.LittleRabbitForms.ToolForms
|
||||
{
|
||||
public partial class TokenNewForm : LRBaseForm
|
||||
{
|
||||
public TokenNewForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.splitContainer2.SplitterWidth = 1;
|
||||
}
|
||||
|
||||
private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
string name = dataGridView3.Columns[e.ColumnIndex].HeaderText;
|
||||
string token = dataGridView3.Rows[e.RowIndex].Cells["TokenColumn"].Value.ParseToString();
|
||||
switch (name)
|
||||
{
|
||||
case "选择":
|
||||
bool ok = !bool.Parse(dataGridView3.Rows[e.RowIndex].Cells["onSelectColumn"].Value.ToString());
|
||||
dataGridView3.Rows[e.RowIndex].Cells["onSelectColumn"].Value = ok;
|
||||
break;
|
||||
case "激活":
|
||||
CaptchaToken(token);
|
||||
break;
|
||||
case "检测":
|
||||
CheckToken(new string[] { token });
|
||||
break;
|
||||
case "删除":
|
||||
DeleteToken(e.RowIndex);
|
||||
SaveConfig();
|
||||
break;
|
||||
default:
|
||||
dataGridView3.Rows[e.RowIndex].Cells["onSelectColumn"].Value = !(bool)dataGridView3.Rows[e.RowIndex].Cells["onSelectColumn"].Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void DeleteToken(string token)
|
||||
{
|
||||
DataGridViewRow dgvr = dataGridView3.Rows.Cast<DataGridViewRow>().Where(p => p.Cells["TokenColumn"].Value.ParseToString() == token).FirstOrDefault();
|
||||
if (dgvr != null)
|
||||
{
|
||||
DeleteToken(dgvr.Index);
|
||||
}
|
||||
}
|
||||
private void CaptchaToken(string token)
|
||||
{
|
||||
PinDuoDuoCaptchaForm pinDuoDuoCaptchaForm = new PinDuoDuoCaptchaForm(token);
|
||||
pinDuoDuoCaptchaForm.onSaveComplete += PinDuoDuoCaptchaForm_SaveComplete;
|
||||
pinDuoDuoCaptchaForm.ShowDialog();
|
||||
SaveConfig();
|
||||
}
|
||||
private void PinDuoDuoCaptchaForm_SaveComplete(object param)
|
||||
{
|
||||
TData<string> obj = param as TData<string>;
|
||||
if (obj.Tag == 1)
|
||||
{
|
||||
CheckToken(new string[] { obj.Result });
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteToken(obj.Result);
|
||||
SaveConfig();
|
||||
}
|
||||
}
|
||||
private void dataGridView3_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
||||
{
|
||||
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dataGridView3.RowHeadersWidth - 4, e.RowBounds.Height);
|
||||
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dataGridView3.RowHeadersDefaultCellStyle.Font, rectangle,
|
||||
dataGridView3.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
|
||||
}
|
||||
private List<string> GetCheckedTokenList()
|
||||
{
|
||||
List<string> tokenList = new List<string>();
|
||||
for (int i = 0; i < dataGridView3.Rows.Count; i++)
|
||||
{
|
||||
bool onSelect = bool.Parse(dataGridView3.Rows[i].Cells["onSelectColumn"].Value.ToString());
|
||||
if (onSelect)
|
||||
{
|
||||
string token = dataGridView3.Rows[i].Cells["TokenColumn"].Value.ToString();
|
||||
tokenList.Add(token);
|
||||
}
|
||||
}
|
||||
return tokenList;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.button1.Text == "检测Token")
|
||||
{
|
||||
List<string> tokenList = GetCheckedTokenList();
|
||||
if (tokenList.Count == 0)
|
||||
{
|
||||
BaseMsgForm.ShowInfo("请选择需要检测的Token码");
|
||||
return;
|
||||
}
|
||||
CheckToken(tokenList.ToArray(), isSaveToServer);
|
||||
this.button1.Text = "停止检测";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.button1.Text = "检测Token";
|
||||
this.statusBar.lblTaskStatus.Text = "用户取消";
|
||||
this.statusBar.pgbTaskProgress.Value = this.statusBar.pgbTaskProgress.Maximum;
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
}
|
||||
private bool isSaveToServer = true;
|
||||
private CancellationTokenSource cancellationTokenSource = null;
|
||||
private void CheckToken(string[] pddAccessTokenArr, bool isSaveToServer = false)
|
||||
{
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
this.statusBar.lblTaskStatus.Text = "正在检测...";
|
||||
this.statusBar.pgbTaskProgress.Value = 0;
|
||||
this.statusBar.pgbTaskProgress.Maximum = pddAccessTokenArr.Length;
|
||||
this.statusBar.pgbTaskProgress.Text = "0" + "/" + pddAccessTokenArr.Length;
|
||||
Task.Run(() =>
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < pddAccessTokenArr.Length; i++)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string temp = pddAccessTokenArr[i].Trim();
|
||||
TData<PinDuoDuoTokenInfo> obj = null;
|
||||
if (GetProxyHtml.ips.Count > 0)
|
||||
{
|
||||
obj = CheckPDDAccessToken(temp, 1);
|
||||
if (obj.Result.ProductDetailStatus == 1)
|
||||
{
|
||||
sb.Append(temp + ",");
|
||||
}
|
||||
}
|
||||
if (obj == null || obj.Result == null)
|
||||
{
|
||||
obj = CheckPDDAccessToken(temp, 0);
|
||||
if (obj.Result.ProductDetailStatus == 1)
|
||||
{
|
||||
sb.Append(temp + ",");
|
||||
}
|
||||
}
|
||||
if (this.Created)
|
||||
{
|
||||
if (i % 5 == 0 || i == pddAccessTokenArr.Length - 1)
|
||||
{
|
||||
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在检测...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + pddAccessTokenArr.Length;
|
||||
}));
|
||||
}
|
||||
AddToken(obj.Result);
|
||||
}
|
||||
//AddToken(obj.Result);
|
||||
}
|
||||
if (isSaveToServer)
|
||||
{
|
||||
string pddAccessToken = sb.ToString().Trim(',');
|
||||
if (!string.IsNullOrEmpty(pddAccessToken))
|
||||
{
|
||||
SaveToken(pddAccessToken);
|
||||
}
|
||||
}
|
||||
if (this.Created)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.button1.Text = "检测Token";
|
||||
this.statusBar.lblTaskStatus.Text = "检测完毕";
|
||||
}));
|
||||
}
|
||||
SaveConfig();
|
||||
});
|
||||
}
|
||||
public void SaveToken(string pddAccessToken)
|
||||
{
|
||||
string url = BaseClass.BuildObjString("sign");
|
||||
string data = UserLogin.GetSignaturex() +
|
||||
"&act=add_token" +
|
||||
"&token=" + pddAccessToken;
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
}
|
||||
private void SaveConfig()
|
||||
{
|
||||
SavePinDuoDuoAccessToken();
|
||||
}
|
||||
public static void SavePinDuoDuoAccessToken()
|
||||
{
|
||||
SaveConfig("temp/pinduoduo_token", PinduoduoProductCollect.PinDuoDuoTokenList);
|
||||
}
|
||||
public static void SaveConfig<T>(string fileName, T config)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + fileName;
|
||||
if (!Directory.Exists(Path.GetDirectoryName(filePath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
}
|
||||
string content = JsonConvert.SerializeObject(config);
|
||||
File.WriteAllText(filePath, content, Encoding.UTF8);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void AddToken(PinDuoDuoTokenInfo param)
|
||||
{
|
||||
PinDuoDuoTokenInfo tokenInfo = PinduoduoProductCollect.PinDuoDuoTokenList.Where(p => p.PDDAccessToken == param.PDDAccessToken).FirstOrDefault();
|
||||
if (tokenInfo == null)
|
||||
{
|
||||
PinduoduoProductCollect.PinDuoDuoTokenList.Add(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenInfo.UserId = param.UserId;
|
||||
tokenInfo.ProductDetailStatus = param.ProductDetailStatus;
|
||||
tokenInfo.LoginStatus = param.LoginStatus;
|
||||
tokenInfo.SearchStatus = param.SearchStatus;
|
||||
tokenInfo.IsCaptcha = param.IsCaptcha;
|
||||
}
|
||||
AddDataGridViewRowToken(param);
|
||||
}
|
||||
private void UpdateDataGridViewRowToken(DataGridViewRow dgvr, PinDuoDuoTokenInfo param)
|
||||
{
|
||||
dgvr.Cells["StatusColumn"].Value = (param.ProductDetailStatus == 1 ? "正常" : "不能用");
|
||||
dgvr.Cells["loginStatusColumn"].Value = (param.LoginStatus == 1 ? "正常" : "不能用");
|
||||
dgvr.Cells["colSearchStatusColumn"].Value = (param.SearchStatus == 1 ? "正常" : "不能用");
|
||||
//dgvr.Cells["colCaptchaColumn"].Value = (param.IsCaptcha ? "激活" : string.Empty);
|
||||
dgvr.Cells["colCaptchaColumn"].Value = "激活";
|
||||
}
|
||||
private void AddDataGridViewRowToken(PinDuoDuoTokenInfo param)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
DataGridViewRow dgvr = dataGridView3.Rows.Cast<DataGridViewRow>().Where(p => p.Cells["TokenColumn"].Value.ToString() == param.PDDAccessToken).FirstOrDefault();
|
||||
if (dgvr != null)
|
||||
{
|
||||
UpdateDataGridViewRowToken(dgvr, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dataGridView3.Rows.Add(
|
||||
false,
|
||||
param.PDDAccessToken,
|
||||
param.LoginStatus == 1 ? "正常" : "未登录",
|
||||
param.SearchStatus == 1 ? "正常" : "不能用",
|
||||
param.ProductDetailStatus == 1 ? "正常" : "不能用",
|
||||
//param.IsCaptcha ? "激活" : string.Empty,
|
||||
"激活",
|
||||
"检测",
|
||||
"删除"
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public TData<PinDuoDuoTokenInfo> CheckPDDAccessToken(string pddAccessToken, int flag = 0)
|
||||
{
|
||||
TData<PinDuoDuoTokenInfo> obj = new TData<PinDuoDuoTokenInfo>();
|
||||
obj.Result = new PinDuoDuoTokenInfo
|
||||
{
|
||||
PDDAccessToken = pddAccessToken
|
||||
};
|
||||
string url = BaseClass.NewUrl+"/personal.html";
|
||||
string refere = "";
|
||||
string html = "";
|
||||
if (flag == 1)
|
||||
html = GetProxyHtml.UploadProxyTaobao(url, refere, true, "PDDAccessToken=" + pddAccessToken);
|
||||
else
|
||||
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, "PDDAccessToken=" + pddAccessToken);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
{
|
||||
obj.Result.LoginStatus = obj.Result.ProductDetailStatus = -1;
|
||||
}
|
||||
else if (html.Contains("我的订单"))
|
||||
{
|
||||
obj.Result.LoginStatus = 1;
|
||||
url = "http://yangkeduo.com/goods.html?goods_id=17252982258";
|
||||
if (flag == 1)
|
||||
{
|
||||
html = GetProxyHtml.UploadProxyTaobao(url, refere, true, "PDDAccessToken=" + pddAccessToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
html = GetProductDetail(url, pddAccessToken);
|
||||
if (!IsNotPinDuoDuoProductDetail(html))
|
||||
{
|
||||
if (html.Contains("垃圾桶"))
|
||||
{
|
||||
obj.Result.ProductDetailStatus = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
html = GetProductDetailByApi(17252982258, pddAccessToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (html.Contains("goodsName")|| html.Contains("垃圾桶"))
|
||||
{
|
||||
obj.Result.ProductDetailStatus = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Result.ProductDetailStatus = -1;
|
||||
obj.Result.IsCaptcha = true;
|
||||
}
|
||||
url = "http://yangkeduo.com/search_result.html?search_key=垃圾桶";
|
||||
if (flag == 1)
|
||||
html = GetProxyHtml.UploadProxyTaobao(url, refere, true, "PDDAccessToken=" + pddAccessToken);
|
||||
else
|
||||
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, "PDDAccessToken=" + pddAccessToken);
|
||||
|
||||
if (html.Contains("goodsName"))
|
||||
{
|
||||
obj.Result.SearchStatus = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int keyWordIndex = url.LastIndexOf('=');
|
||||
if (keyWordIndex > 0)
|
||||
{
|
||||
var keyWord = url.Substring(keyWordIndex + 1);
|
||||
if (html.Contains(keyWord))
|
||||
{
|
||||
obj.Result.SearchStatus = -1;
|
||||
}
|
||||
}
|
||||
obj.Result.IsCaptcha = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Result.LoginStatus = -1;
|
||||
obj.Result.IsCaptcha = true;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
public string GetProductDetailByApi(long productId, string pddAccessToken)
|
||||
{
|
||||
string url = "https://yangkeduo.com/proxy/api/api/oak/integration/render?pdduid={0}";
|
||||
HttpParam httpParam = new HttpParam();
|
||||
string cookie = "PDDAccessToken=" + pddAccessToken;
|
||||
Dictionary<string, string> cookieDict = GetCookieDictionary(cookie);
|
||||
string key = "pdd_user_id";
|
||||
if (cookieDict.ContainsKey(key))
|
||||
{
|
||||
httpParam.Url = string.Format(url, cookieDict[key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
httpParam.Url = string.Format(url, 0);
|
||||
}
|
||||
httpParam.ContentType = "application/json;charset=UTF-8";
|
||||
httpParam.PostData = JsonConvert.SerializeObject(new
|
||||
{
|
||||
page_version = "7",
|
||||
goods_id = productId,
|
||||
page_from = 0,
|
||||
hostname = "yangkeduo.com",
|
||||
client_time =GetUnixMilliSecondTimeStamp(DateTime.Now) + BaseClass.TimeDifferent * 1000
|
||||
});
|
||||
AddHeader(httpParam, "AccessToken", pddAccessToken);
|
||||
AddRequestParamForPinDuoDuoWeb(httpParam, pddAccessToken);
|
||||
string html = Post(httpParam);
|
||||
if (html.Contains("goods_id") && html.Contains("mall_id"))
|
||||
{
|
||||
JObject jObj = JObject.Parse(html);
|
||||
return html;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static string Post(HttpParam httpParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = GetHttpWebRequest(httpParam);
|
||||
request.Method = "Post";
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
byte[] postDataByte = Encoding.UTF8.GetBytes(httpParam.PostData);
|
||||
request.ContentLength = postDataByte.Length;
|
||||
request.AllowAutoRedirect = false;
|
||||
using (Stream requestStream = request.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(postDataByte, 0, postDataByte.Length);
|
||||
}
|
||||
return ReadResponse(httpParam, (HttpWebResponse)request.GetResponse());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
public static long GetUnixMilliSecondTimeStamp(DateTime dt)
|
||||
{
|
||||
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
||||
return (long)(dt - startTime).TotalMilliseconds;
|
||||
}
|
||||
public static bool IsNotPinDuoDuoProductDetail(string html)
|
||||
{
|
||||
return !html.Contains("topGallery") && !html.Contains("商品不存在") && !html.Contains("商品已下架") && !html.Contains("\"mall\"");
|
||||
}
|
||||
public string GetProductDetail(string url, string pddAccessToken)
|
||||
{
|
||||
HttpParam httpParam = new HttpParam { Url = url };
|
||||
AddRequestParamForPinDuoDuoWeb(httpParam, pddAccessToken);
|
||||
string html = Get(httpParam);
|
||||
return html;
|
||||
}
|
||||
public static string UserAgent = "Mozilla/5.0 (Linux; Android 7.1.1; OD103 Build/NMF26F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.84 Mobile Safari/537.36";
|
||||
private void AddRequestParamForPinDuoDuoWeb(HttpParam httpParam, string accessToken)
|
||||
{
|
||||
httpParam.Cookie = "PDDAccessToken=" + accessToken;
|
||||
httpParam.UserAgent = UserAgent;
|
||||
if (!string.IsNullOrEmpty(httpParam.Cookie))
|
||||
{
|
||||
Dictionary<string, string> cookieDict = GetCookieDictionary(httpParam.Cookie);
|
||||
string key = "VerifyAuthToken";
|
||||
if (cookieDict.ContainsKey(key))
|
||||
{
|
||||
AddHeader(httpParam, key, cookieDict[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void AddHeader(HttpParam httpParam, string key, string value)
|
||||
{
|
||||
if (httpParam.Header == null)
|
||||
{
|
||||
httpParam.Header = new Dictionary<string, string>();
|
||||
}
|
||||
httpParam.Header.Remove(key);
|
||||
httpParam.Header.Add(key, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// 字符串转成Cookie Dictionary
|
||||
/// </summary>
|
||||
/// <param name="cookie"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> GetCookieDictionary(string cookie)
|
||||
{
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
string[] cookieArr = SplitToArray<string>(cookie, ';');
|
||||
foreach (string line in cookieArr)
|
||||
{
|
||||
int index = line.IndexOf('=');
|
||||
if (index > 0)
|
||||
{
|
||||
string key = line.Substring(0, index);
|
||||
string value = line.Substring(index + 1);
|
||||
if (!dict.ContainsKey(key))
|
||||
{
|
||||
dict.Add(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
public static T[] SplitToArray<T>(string value, char split)
|
||||
{
|
||||
T[] arr = value.Split(new string[] { split.ToString() }, StringSplitOptions.RemoveEmptyEntries).CastSuper<T>().ToArray();
|
||||
return arr;
|
||||
}
|
||||
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
isSaveToServer = checkBox1.Checked;
|
||||
}
|
||||
|
||||
private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private void TextBoxForm_SaveComplete(object param)
|
||||
{
|
||||
string[] lineArr = param.ParseToString().Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray();
|
||||
List<string> tokenList = new List<string>();
|
||||
foreach (string token in lineArr)
|
||||
{
|
||||
string[] tokenArr = token.Split(new string[] { "----" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
switch (tokenArr.Length)
|
||||
{
|
||||
case 1:
|
||||
tokenList.Add(token);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// 第三个是token,格式为 14704717242----9496706479025----5FMVBP7QAK4DQNJO6NE3225GGSLBQEO2S5LT4GF3DUD2BVJVEW5Q103b187
|
||||
tokenList.Add(tokenArr[2]);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// 第二个是token,格式为 13598846146----B6SD4DVKPFKTK5ZX5MWGOAS3TK6HIJNMK4AVJ6SZAZDVL4CTSP5Q110e49e----5054402823396----3045303225
|
||||
tokenList.Add(tokenArr[1]);
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach (string split in tokenArr)
|
||||
{
|
||||
// 拼多多的token是59个字符
|
||||
if (split.Length == 59)
|
||||
{
|
||||
tokenList.Add(split);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
CheckToken(tokenList.ToArray(), isSaveToServer);
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
RefreshDataGridView();
|
||||
}
|
||||
|
||||
public bool isLoading = false;
|
||||
private void RefreshDataGridView()
|
||||
{
|
||||
if (isLoading)
|
||||
{
|
||||
BaseMsgForm.ShowInfo("当前正在加载,请稍等");
|
||||
return;
|
||||
}
|
||||
this.statusBar.pgbTaskProgress.Maximum = PinduoduoProductCollect.PinDuoDuoTokenList.Count;
|
||||
Task.Run(() =>
|
||||
{
|
||||
isLoading = true;
|
||||
for (int i = 0; i < PinduoduoProductCollect.PinDuoDuoTokenList.Count; i++)
|
||||
{
|
||||
if (i % 5 == 0 || i == PinduoduoProductCollect.PinDuoDuoTokenList.Count - 1)
|
||||
{
|
||||
if (this.Created)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在加载...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + PinduoduoProductCollect.PinDuoDuoTokenList.Count;
|
||||
}));
|
||||
}
|
||||
}
|
||||
AddDataGridViewRowToken(PinduoduoProductCollect.PinDuoDuoTokenList[i]);
|
||||
}
|
||||
if (this.Created)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "加载完毕";
|
||||
}));
|
||||
}
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
private void textBox2_Click(object sender, EventArgs e)
|
||||
{
|
||||
TextForm textForm = new TextForm();
|
||||
textForm.onSaveComplete += TextBoxForm_SaveComplete;
|
||||
textForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void textBox1_Click(object sender, EventArgs e)
|
||||
{
|
||||
PinDuoDuoLoginForm pinDuoDuoLoginForm = new PinDuoDuoLoginForm();
|
||||
pinDuoDuoLoginForm.onSaveComplete += PinDuoDuoLoginForm_SaveComplete;
|
||||
pinDuoDuoLoginForm.ShowDialog();
|
||||
}
|
||||
private void PinDuoDuoLoginForm_SaveComplete(object obj)
|
||||
{
|
||||
CheckToken(new string[] { obj.ParseToString() }, true);
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<DataGridViewRow> dataGridViewRowList = dataGridView3.Rows.Cast<DataGridViewRow>().Where(p => p.Cells["onSelectColumn"].Value.ToString() == "True").ToList();
|
||||
if (!dataGridViewRowList.Any())
|
||||
{
|
||||
BaseMsgForm.ShowInfo("请选择需要删除的Token码");
|
||||
return;
|
||||
}
|
||||
foreach (DataGridViewRow dgvr in dataGridViewRowList)
|
||||
{
|
||||
DeleteToken(dgvr.Index);
|
||||
}
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
private void DeleteToken(int rowIndex)
|
||||
{
|
||||
string token = this.dataGridView3.Rows[rowIndex].Cells["TokenColumn"].Value.ParseToString();
|
||||
dataGridView3.Rows.RemoveAt(rowIndex);
|
||||
PinduoduoProductCollect.PinDuoDuoTokenList.RemoveAll(p => p.PDDAccessToken == token);
|
||||
}
|
||||
|
||||
private void TokenNewForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (BaseClass.Ico != null)
|
||||
Icon = BaseClass.Ico;
|
||||
this.statusBar.pgbTaskProgress.Minimum = 0;
|
||||
RefreshDataGridView();
|
||||
}
|
||||
|
||||
private void selectAllcheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < dataGridView3.Rows.Count; i++)
|
||||
{
|
||||
dataGridView3.Rows[i].Cells["onSelectColumn"].Value = selectAllcheckBox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox2_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < dataGridView3.Rows.Count; i++)
|
||||
{
|
||||
if (checkBox2.Checked && dataGridView3.Rows[i].Cells["StatusColumn"].Value.ToString() == "不能用")
|
||||
{
|
||||
dataGridView3.Rows[i].Cells["onSelectColumn"].Value = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGridView3.Rows[i].Cells["onSelectColumn"].Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox3_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < dataGridView3.Rows.Count; i++)
|
||||
{
|
||||
if (checkBox3.Checked && dataGridView3.Rows[i].Cells["StatusColumn"].Value.ToString() == "正常")
|
||||
{
|
||||
dataGridView3.Rows[i].Cells["onSelectColumn"].Value = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGridView3.Rows[i].Cells["onSelectColumn"].Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string Get(HttpParam httpParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = GetHttpWebRequest(httpParam);
|
||||
request.Method = "Get";
|
||||
return ReadResponse(httpParam, (HttpWebResponse)request.GetResponse());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadResponse(HttpParam httpParam, HttpWebResponse response)
|
||||
{
|
||||
using (Stream stream = DecompressStream(response))
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(stream, httpParam.ResponseEncoding))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static Stream DecompressStream(HttpWebResponse response)
|
||||
{
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
Stream stream = null;
|
||||
if (response.ContentEncoding.ToLower().Contains("gzip"))
|
||||
{
|
||||
stream = new GZipStream(responseStream, CompressionMode.Decompress);
|
||||
}
|
||||
else if (response.ContentEncoding.ToLower().Contains("deflate"))
|
||||
{
|
||||
stream = new DeflateStream(responseStream, CompressionMode.Decompress);
|
||||
}
|
||||
if (stream == null)
|
||||
{
|
||||
return responseStream;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
public static HttpWebRequest GetHttpWebRequest(HttpParam param)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(param.Url);
|
||||
if (param.Proxy != null)
|
||||
{
|
||||
request.Proxy = param.Proxy;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// request.Proxy = NaiBaGlobalConfig.GetDevelopProxy();
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(param.UserAgent))
|
||||
{
|
||||
request.UserAgent = param.UserAgent;
|
||||
}
|
||||
else
|
||||
{
|
||||
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(param.Accept))
|
||||
{
|
||||
request.Accept = param.Accept;
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
||||
}
|
||||
if (string.IsNullOrEmpty(param.AcceptLanguage))
|
||||
{
|
||||
request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Headers.Add("Accept-Language", param.AcceptLanguage);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(param.ContentType))
|
||||
{
|
||||
request.ContentType = param.ContentType;
|
||||
}
|
||||
else
|
||||
{
|
||||
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(param.Referer))
|
||||
{
|
||||
request.Referer = param.Referer;
|
||||
}
|
||||
request.Headers.Remove("Cookie");
|
||||
if (!string.IsNullOrEmpty(param.Cookie))
|
||||
{
|
||||
request.Headers.Add("Cookie", param.Cookie);
|
||||
}
|
||||
if (param.Header != null)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> header in param.Header)
|
||||
{
|
||||
request.Headers.Add(header.Key, header.Value);
|
||||
}
|
||||
}
|
||||
if (param.Timeout > 0)
|
||||
{
|
||||
request.Timeout = param.Timeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Timeout = 60 * 1000;
|
||||
}
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum UserAgentTypeEnum
|
||||
{
|
||||
[Description("未知")]
|
||||
Unknown = 0,
|
||||
|
||||
[Description("PC")]
|
||||
PC = 1,
|
||||
|
||||
[Description("Mobile")]
|
||||
Mobile = 2,
|
||||
|
||||
[Description("Pad")]
|
||||
Pad = 3
|
||||
}
|
||||
public class HttpParam
|
||||
{
|
||||
public HttpParam()
|
||||
{
|
||||
ResponseEncoding = Encoding.UTF8;
|
||||
}
|
||||
public string Url { get; set; }
|
||||
public string Method { get; set; }
|
||||
public string PostData { get; set; }
|
||||
public string ContentType { get; set; }
|
||||
public string Cookie { get; set; }
|
||||
public string Referer { get; set; }
|
||||
public string UserAgent { get; set; }
|
||||
public UserAgentTypeEnum UserAgentType { get; set; }
|
||||
public string AcceptLanguage { get; set; }
|
||||
public string Accept { get; set; }
|
||||
[JsonIgnore]
|
||||
public WebProxy Proxy { get; set; }
|
||||
public int Timeout { get; set; }
|
||||
public Dictionary<string, string> Header { get; set; }
|
||||
public int ProxySleep { get; set; }
|
||||
public int TryTimes { get; set; }
|
||||
public int ActualTryTimes { get; set; }
|
||||
[JsonIgnore]
|
||||
public CancellationTokenSource CancellationTokenSource { get; set; }
|
||||
[JsonIgnore]
|
||||
public Encoding ResponseEncoding { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user