try { for (int i = 1; i < 130; i++) { var html = GetHtmls("http://bbs.fobshanghai.com/viewthread.php?tid=3885995&extra=&page="+i,"","","gbk"); var ms = Regex.Matches(html, @"<table[sS]+?</table"); File.AppendAllText("1.html",string.Format( "<h4>第{0}页</h4><hr>",i)); foreach (Match m in ms) { var temp = m.Groups[0].Value; if (!temp.Contains("鱼骨的个人空间")) continue; var m1 = Regex.Match(temp, @"t_msgfont"">([sS]+?)</div>s+<br"); var str = m1.Groups[1].Value; str = Regex.Replace(str, @"[<i>s*本帖最后由.+?编辑s*</i>]", ""); File.AppendAllText("1.html","<p>"+str+"</p>"); } } MessageBox.Show("over"); } catch (Exception ex) { MessageBox.Show(ex.Message); }
看到这帖子不错 http://bbs.fobshanghai.com/viewthread.php?tid=3885995&extra=&page=1
写了一段代码 进行采集,看着方便多了
365的
try { for (int i = 1; i < 36; i++) { var html = GetHtmls("http://xxxxxxx/thread-536585-"+i+"-1.html"); var ms = Regex.Matches(html, @"<tr><tds+width=""20%""s+align=""left""s+nowrap>[sS]+?id=""msg"">([sS]+?)</div>"); File.AppendAllText("365.html", string.Format("<h4>第{0}页</h4><hr>", i)); foreach (Match m in ms) { var temp = m.Groups[0].Value; if (!temp.Contains("5>yswgxx</font>")) continue; var m1 = Regex.Match(temp, @"(<fonts+color=blue>[sS]+?)</td>"); var str = m1.Groups[1].Value;
str = str+"<br>"+m.Groups[1].Value;
File.AppendAllText("365.html", "<p>" + str.Replace("<font color=#A7CF7A><i><b>------ 发表于安卓手机365App</b></i></font>","") + "</p>");
} //break; } MessageBox.Show("over"); } catch (Exception ex) { MessageBox.Show(ex.Message); }