Files
KJD/TEMUKJD/KJDForms/UploadForms/GetUpProductForm.cs
T
2025-06-29 19:38:31 +08:00

136 lines
5.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AllBase;
using LittleRabbit.LittleRabbitForms.BaseForms;
using NaiBa.Util;
using NaiBa.Util.Extension;
using NaiBa.Util.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Work;
namespace LittleRabbit.LittleRabbitForms.UploadForms
{
public partial class GetUpProductForm : Form
{
public GetUpProductForm()
{
InitializeComponent();
}
private void btnSearch_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtIds.Text.Trim()))
{
BaseMsgForm.ShowError("请输入商品ID!");
return;
}
var idArr = this.txtIds.Text.Trim().Split(new string[] { "\r", "\n", ",", ",", ";", "-----" }, StringSplitOptions.RemoveEmptyEntries);
idArr = idArr.Take(20).ToArray();
foreach (var prodId in idArr)
{
var product_id = prodId.ParseToLong();
if (product_id > 0)
{
string url = BaseClass.LoginApiUrl + "?obj=upshopid/upid_dd&act=get";
string data = "&pid=" + product_id + "&table=" + (product_id % 1024);
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex("", "") + data);
string upId = BaseRegex.GetMatchRegexString(html, @"([\d]+)");
string upUrl = "";
if (html.StartsWith("tb"))
upUrl = "https://item.taobao.com/item.htm?id=" + upId;
if (html.StartsWith("pd"))
upUrl = "https://mobile.yangkeduo.com/goods.html?goods_id=" + upId;
if (html.StartsWith("al"))
upUrl = "https://detail.1688.com/offer/" + upId + ".html";
if (html.StartsWith("jx"))
upUrl = "https://item.jd.com/" + upId + ".html";
if (html.StartsWith("dy"))
upUrl = "https://haohuo.jinritemai.com/views/product/detail?id=" + upId;
if (string.IsNullOrEmpty(upId))
upUrl = "https://www.baidu.com";
FileHelper.OpenUrl(upUrl + (upUrl.Contains("?") ? "&" : "?") + "lr_search_id=" + product_id);
//GetHtml.OpenUrl(upUrl + (upUrl.Contains("?") ? "&" : "?") + "lr_search_id=" + product_id);
}
else
{
BaseMsgForm.ShowError("输入商品Id错误!");
break;
}
}
}
private void pbPaste_Click(object sender, EventArgs e)
{
if (BaseClass.UserName == "18888888888")
{
this.buttonX1.Visible = true;
}
IDataObject iData = Clipboard.GetDataObject();
if (iData != null && iData.GetDataPresent(DataFormats.Text))
{
txtIds.Text = (string)iData.GetData(DataFormats.Text);
}
}
private void buttonX1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtIds.Text.Trim()))
{
BaseMsgForm.ShowError("请输入商品ID!");
return;
}
dgvProduct.Visible = true;
dgvProduct.Rows.Clear();
var idArr = this.txtIds.Text.Trim().Split(new string[] { "\r", "\n", ",", ",", ";", "-----" }, StringSplitOptions.RemoveEmptyEntries);
//idArr = idArr.Take(20).ToArray();
Task.Run(() =>
{
foreach (var prodId in idArr)
{
Thread.Sleep(50);
var product_id = prodId.ParseToLong();
if (product_id > 0)
{
string url = BaseClass.LoginApiUrl + "?obj=upshopid/upid_dd&act=get";
string data = "&pid=" + product_id + "&table=" + (product_id % 1024);
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex("", "") + data);
string upId = BaseRegex.GetMatchRegexString(html, @"([\d]+)");
string upUrl = "";
string from = "";
if (html.StartsWith("tb"))
from = "淘宝";
if (html.StartsWith("pd"))
from = "拼多多";
if (html.StartsWith("al"))
from = "阿里";
if (html.StartsWith("jx"))
from = "京东";
if (html.StartsWith("dy"))
from = "抖音";
Invoke(new Action(() =>
{
this.dgvProduct.Rows.Add(false, product_id, from, html.Split('-').LastOrDefault());
}));
}
else
{
BaseMsgForm.ShowError("输入商品Id错误!");
break;
}
}
});
}
}
}