public static bool Is_Tid(string Tid) { DbcontextDB db = new DbcontextDB(); var ID = db.FirstOrDefault <Tieba>("where Tid=" + Tid + ""); return(ID == null ? true : false); }
public static bool Is_Id(string newsid) { DbcontextDB db = new DbcontextDB(); var ID = db.FirstOrDefault <Crawler>("where NewsID=" + newsid + ""); return(ID == null ? true : false); }
public static bool InsertTieba(Tieba Tb) { bool ok; DbcontextDB db = new DbcontextDB(); int row = Convert.ToInt32(db.Insert(Tb)); return(row == 1 ? ok = false : ok = true); }
public static bool Insert(Crawler cl) { bool ok; DbcontextDB db = new DbcontextDB(); int row = Convert.ToInt32(db.Insert(cl)); return(row == 1 ? ok = false : ok = true); }
public static IEnumerable <Tieba> tieba(string title, string name) { DbcontextDB db = new DbcontextDB(); Sql sql = Sql.Builder.Select("*"); sql.From("Tieba"); if (!string.IsNullOrEmpty(name)) { sql.Where("username=@0", name); } if (!string.IsNullOrEmpty(title)) { sql.Where("title like @0", "%" + title + "%"); } string Tsql = sql.ToString(); return(db.Query <Tieba>(sql));; }
public static void clearHtmlattrbute(string html) { HtmlDocument hd = new HtmlDocument(); hd.LoadHtml(html); var list = hd.DocumentNode.SelectNodes(".//div[@class='col2_right j_threadlist_li_right ']"); foreach (var item in list) { var Tid = item.SelectSingleNode("./div[1]/div[1]/a[1]").Attributes["href"].Value; Tid = Tid.Substring(3, Tid.Length - 3);//贴吧ID if (Tid.Length == 10) { using (DbcontextDB db = new DbcontextDB()) { var IsNew = db.FirstOrDefault <Tieba>("where Tid=@Tid", new { Tid = Tid }); if (IsNew == null) { var modul = Task.Run(() => GetTieba(item)); modul.Result.Tid = Tid; var IsAdd = Task.Run(() => AddTieba(modul.Result)); if (!IsAdd.Result) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"标题:{modul.Result.title}添加失败!"); } } } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Tid 有误,请查看"); } } }
public static bool AddTieba(Tieba T) { DbcontextDB db = new DbcontextDB(); return(Convert.ToInt32(db.Insert(T)) > 0); }