54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using NaiBa.Util;
|
|
using NaiBa.Util.Extension;
|
|
using NaiBa.Util.Helper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Work.BLL.Collect
|
|
{
|
|
public class PddSameScreeningBLL
|
|
{
|
|
#region http请求
|
|
public static List<string> listIp = new List<string>();
|
|
public static List<string> InitIp(string ProxyUrl, out bool IsOverdue)
|
|
{
|
|
IsOverdue = false;
|
|
if (listIp.Count > 0)
|
|
{
|
|
return listIp;
|
|
}
|
|
HttpParam httpParm = new HttpParam { Url = ProxyUrl };
|
|
GlobalProxyHelper.SetAuthorization(httpParm);
|
|
string proxyIpHtml = string.Empty;
|
|
List<string> proxyIpList = new List<string>();
|
|
int tryTimes = 0;
|
|
int maxTryTimes = 10;
|
|
while (true && tryTimes <= maxTryTimes)
|
|
{
|
|
proxyIpHtml = HttpHelper.Get(httpParm);
|
|
if (proxyIpHtml.Contains("过期") || proxyIpHtml.Contains("套餐不存在"))
|
|
{
|
|
IsOverdue = true;
|
|
break;
|
|
}
|
|
if (!string.IsNullOrEmpty(proxyIpHtml) && !proxyIpHtml.Contains("后获取") && !proxyIpHtml.Contains("过期") && !proxyIpHtml.Contains("套餐不存在"))
|
|
{
|
|
proxyIpList = proxyIpHtml.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList();
|
|
break;
|
|
}
|
|
tryTimes++;
|
|
Thread.Sleep(3000);
|
|
}
|
|
return proxyIpList;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|