日期:2014-05-17 浏览次数:20998 次
string ListUrl = "http://XXXX.cc/html/yazhou/index{0}.html";
System.Net.WebClient wc = new System.Net.WebClient();
HtmlAgilityPack.HtmlDocument listdoc = new HtmlAgilityPack.HtmlDocument();
HtmlAgilityPack.HtmlNode listbody=null;
HtmlAgilityPack.HtmlDocument cotentdoc = new HtmlAgilityPack.HtmlDocument();
HtmlAgilityPack.HtmlNode cotentbody = null;
for (int i = 1; i <= 33; i++)
{
string tempList = string.Format(ListUrl, i == 1 ? "" : i.ToString());
string htmlStr = wc.DownloadString(tempList);
if (htmlStr == null) continue;
listdoc.LoadHtml(htmlStr);
listbody = listdoc.DocumentNode;
HtmlAgilityPack.HtmlNodeCollection lists = listbody.SelectNodes("//div/ul/li");
foreach (HtmlNode list in lists)
{
var listname = list.SelectSingleNode("./a").Attributes["title"].Value;
var contenturl = "http://XXXX.cc/" + list.SelectSingleNode("./a").Attributes["href"].Value;
try
{
int end = 1;
int tonum=1;
for (int m = 1; m <= end; m++)
{
&nbs