|
发表于 2019-8-18 20:33:48
|
显示全部楼层
江苏省南京市
xici代理
与89代理不同之处有:
1、 string url = "https://www.xicidaili.com/nn/{index}";
string reg = @"<td>(\d+.\d+.\d+.\d+)</td>\s+<td>(\d+)</td>[\s,\S]+?([\u4e00-\u9fa5]+)[\s,\S]+?(HTTPS?)[\s,\S]+?<td>\d+-\d+-(\d+)\s\d+:\d+</td>";
string rel = await _client.GetStringAsync(url.Replace("{index}", _index.ToString()));
MatchCollection mc = Regex.Matches(rel, reg, RegexOptions.IgnoreCase);
List<ProxyInfo> plist = new List<ProxyInfo>();
ProxyInfo p;
foreach (Match ma in mc){
if (ma.Success) {
p = new ProxyInfo();
p.Ip = ma.Groups[1].Value;
p.port = Convert.ToInt32(ma.Groups[2].Value);
p.Address = ma.Groups[3].Value;
p.Type = ma.Groups[4].Value;
p.VerifyTime = ma.Groups[5].Value;
if (IsOut(p.VerifyTime)) {//函数出口
ProgressEvent?.Invoke($"当前正在采集{_index}/页", plist);
ProgressComplete?.Invoke("搞完了");
_client.Dispose();
return;
}
plist.Add(p);
}
}
ProgressEvent?.Invoke($"当前正在采集{_index}/页", plist);
_index++;
await Start();
private bool IsOut(string strDay) {//出口条件(前天获取的就不要了)
int dayNow = DateTime.Now.Date.Day;
int day = Convert.ToInt32(strDay);
if (dayNow - day > 1) {
return true;
} else {
return false;
}
}
验证
string rel = await client.GetStringAsync("http://www.lyb2019.cn");//轰炸自己网站哈哈哈哈
if (rel.Contains("嘿嘿嘿")){
p.state = true;//可用标位
}
|
|