您好我想在此网站http://proxylist.hidemyass.com
获取IP地址和PORT以及国家/地区名称我是HtmlAgilityPack
的新人,我也不认识Linq。你可以帮助我获得这些价值吗?谢谢。
答案 0 :(得分:0)
WebClient wc = new WebClient();
string src = wc.DownloadString("http://proxylist.hidemyass.com");
HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument();
hd.LoadHtml(src);
HtmlAgilityPack.HtmlNode table = hd.DocumentNode.SelectSingleNode("//tr[@class='#altshade']");
bool First = false;
foreach (HtmlAgilityPack.HtmlNode trs in table.ChildNodes)//.Where(i => i.Name == "tr" && i.InnerText.Trim() != string.Empty))
{
if (First)
{
Proxy p = new Proxy();
foreach (HtmlAgilityPack.HtmlNode tds in trs.ChildNodes.Where(i => i.InnerText.Trim() != string.Empty))
{
MessageBox.Show(tds.InnerText);
}
Proxies.Add(p);
}
First = true;
}