话不多说上代码
举例
淘口令:6.0f/u枝这行 a:/🗝ONQ1c92vrNB🗝回_淘窇【男士韩版格子休闲西服春秋季新款潮流夜场小西装英伦上衣帅气外套】
private void button7_Click(object sender, EventArgs e)
{
///一次输入多个以换行结束
string[] strs = textBox4.Text.ToString().Replace("\r\n", "+").Split('+');
if (strs.Count() > 0)
{
string symbol = "\\₰|\\/|\\//|\\¥|\\(|\\)|\\《|\\¥|\\€|\\$|\\₤|\\₳|\\¢|\\¤|\\฿|\\฿|\\₵|\\₡|\\₫|\\₲|\\₭|\\£|\\₥|\\₦|\\₱|\\〒|\\₮|\\₩|\\₴|\\₪|\\៛|\\﷼|\\₢|ℳ|\\₯|\\₠|\\₣|\\₧|ƒ|🗝|😺";
string str = "(" + symbol + ")([a-zA-Z0-9]{11})(" + symbol + ")";//目前淘口令是11位 + 2个符号
string strTextBox5 = "";
for (int i = 0; i < strs.Count(); i++)
{
try
{
Regex reg = new Regex(str);
Match m = reg.Match(strs[i], 0);
string s = m.Value;
if (s == "")
{
string str2 = "(" + symbol + ")([a-zA-Z0-9]{12})(" + symbol + ")";
Regex reg2 = new Regex(str2);
Match m2 = reg2.Match(strs[i], 0);
if (m2.Value == "")
{
if (strs[i].IndexOf("Http:") > 0)
{
strTextBox5 += strs[i].Substring(strs[i].IndexOf("Http:") + 8, 12) + "\r\n";
}
}
else
{
if (m2.Value.IndexOf("/T") >= 0)
strTextBox5 += m2.Value.Replace("/T", "") + "\r\n";
else
strTextBox5 += m2.Value + "\r\n";
}
}
else
{
if (s.IndexOf("/T") >= 0)
strTextBox5 += s.Replace("/T", "") + "\r\n";
else
strTextBox5 += s + "\r\n";
}
}
catch (Exception ex)
{
strTextBox5 += strs[i].ToString() + "\r\n";
}
}
textBox5.Text = strTextBox5;
}
}
下面是 解析出来的淘口令转url
private void button8_Click(object sender, EventArgs e)
{
string isSuccess = "";
//多个淘口令以换行结束
string[] strs = textBox5.Text.ToString().Replace("\r\n", "+").Split('+');
if (strs.Count() > 0)
{
for (int i = 0; i < strs.Count(); i++)
{
if (strs[i] == "")
{
break;
}
string postData = "{\"apikey\":\"你的apikey\",\"tkl\": \"" + strs[i] + "\"}";
string posturl = "https://api.taokouling.com/tkl/tkljm";
Stream outstream = null;
Stream instream = null;
StreamReader sr = null;
HttpWebResponse response = null;
HttpWebRequest request = null;
Encoding encoding = Encoding.UTF8;
byte[] data = encoding.GetBytes(postData);
try
{
request = WebRequest.Create(posturl) as HttpWebRequest;
CookieContainer cookieContainer = new CookieContainer();
request.CookieContainer = cookieContainer;
request.AllowAutoRedirect = true;
request.Method = "POST";
request.ContentType = "application/json";//x-www-form-urlencoded";
request.ContentLength = data.Length;
outstream = request.GetRequestStream();
outstream.Write(data, 0, data.Length);
outstream.Close();
response = request.GetResponse() as HttpWebResponse;
instream = response.GetResponseStream();
sr = new StreamReader(instream, encoding);
string content = sr.ReadToEnd();
JObject job = JObject.Parse(content);
string s = job["url"].ToString();
if (job["ret"].ToString() == "调用成功")
{
isSuccess += "淘口令url地址:" + job["url"].ToString() + " \r\n\r\n淘口令标题:" + job["content"].ToString() + " \r\n\r\n淘口令剩余时间:" + job["validDate"].ToString();
}
}
catch (Exception ex)
{
string err = ex.Message;
}
isSuccess += "\r\n----------------------------------------------------\r\n\r\n";
}
textBox6.Text = isSuccess;
}
}