This commit is contained in:
parent
3970d268ca
commit
8ac1f62a23
|
@ -205,10 +205,10 @@ namespace Api.Framework
|
|||
Mode = SuperSocket.SocketBase.SocketMode.Tcp,
|
||||
TextEncoding = "UTF-8",
|
||||
Port = port,
|
||||
MaxConnectionNumber = 100 * 5,
|
||||
MaxConnectionNumber = 100 * 5 + 50,
|
||||
ReceiveBufferSize = bufSize,
|
||||
MaxRequestLength = Int32.MaxValue,
|
||||
SendingQueueSize = 300,
|
||||
SendingQueueSize = 400,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1138,35 +1138,32 @@ namespace Api.Framework.Tools
|
|||
|
||||
private string getMTbCn(string url, AlimamaApi api)
|
||||
{
|
||||
try
|
||||
if (!url.ToLower().Contains("m.tb.cn") && !url.ToLower().Contains("s.tb.cn"))
|
||||
{
|
||||
if (!url.ToLower().Contains("m.tb.cn"))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
var urlTmp = url;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpHelper http = new HttpHelper();
|
||||
HttpItem item = new HttpItem()
|
||||
if (urlTmp.Contains("m.tb"))
|
||||
{
|
||||
URL = url,
|
||||
Method = "GET",
|
||||
Timeout = 10000,
|
||||
ReadWriteTimeout = 30000,
|
||||
IsToLower = false,
|
||||
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",
|
||||
Accept = "text/html, application/xhtml+xml, */*",
|
||||
ContentType = "application/x-www-form-urlencoded",
|
||||
Referer = "",
|
||||
Allowautoredirect = true,
|
||||
AutoRedirectCookie = false,
|
||||
Postdata = ""
|
||||
};
|
||||
HttpResult result = http.GetHtml(item);
|
||||
string html = result.Html;
|
||||
urlTmp = urlTmp.Replace("m.tb", "s.tb");
|
||||
}
|
||||
else if (urlTmp.Contains("s.tb"))
|
||||
{
|
||||
urlTmp = urlTmp.Replace("s.tb", "m.tb");
|
||||
}
|
||||
|
||||
LogHelper.GetSingleObj().Error("淘宝解析请求", $"{url} =>> {html}");
|
||||
var html = getTb(urlTmp, api);
|
||||
|
||||
if (html.Contains("操作超时"))
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
continue;
|
||||
}
|
||||
|
||||
var item_id = string.Empty;
|
||||
|
||||
|
@ -1184,13 +1181,48 @@ namespace Api.Framework.Tools
|
|||
item_id = FindTbItemIdByStr(html);
|
||||
if (!string.IsNullOrWhiteSpace(item_id))
|
||||
return item_id;
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.GetSingleObj().Error("淘宝解析请求异常2", $"{urlTmp} -> {ex.Message}");
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
private string getTb(string url, AlimamaApi api)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpHelper http = new HttpHelper();
|
||||
HttpItem item = new HttpItem()
|
||||
{
|
||||
URL = url,
|
||||
Method = "GET",
|
||||
Timeout = 10000,
|
||||
ReadWriteTimeout = 30000,
|
||||
IsToLower = false,
|
||||
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",
|
||||
Accept = "text/html, application/xhtml+xml, */*",
|
||||
ContentType = "application/x-www-form-urlencoded",
|
||||
Referer = "",
|
||||
Allowautoredirect = true,
|
||||
AutoRedirectCookie = false,
|
||||
Postdata = ""
|
||||
};
|
||||
HttpResult result = http.GetHtml(item);
|
||||
string html = result.Html;
|
||||
|
||||
LogHelper.GetSingleObj().Error("淘宝解析请求", $"{url} =>> {html}");
|
||||
|
||||
return html;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.GetSingleObj().Error("淘宝解析请求异常", $"{url} -> {ex.Message}");
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue