private void extract() { BaidudataEntities3 TDB = new BaidudataEntities3(); Instance tab = new Instance(); tab.conceptid = conceptid; string instance = ""; string instanceurl = ""; foreach (HtmlElement td in this.webBrowser1.Document.GetElementsByTagName("td")) { if (td.GetAttribute("className").Equals("f")) { foreach (HtmlElement font in td.GetElementsByTagName("font")) { if (font.GetAttribute("size").Equals("3")) { instance = font.InnerText; tab.instance1 = instance; Console.WriteLine("instance: " + instance); foreach (HtmlElement a in font.GetElementsByTagName("a")) { instanceurl = a.GetAttribute("href"); tab.instanceurl = instanceurl; Console.WriteLine("instanceurl: " + instanceurl); TDB.Instance.Add(tab); TDB.SaveChanges(); } } } } } indexExtract += 10; string urltemp = urla + "&offset=" + indexExtract; Console.WriteLine(urltemp); if (indexExtract <= countOffset()) { this.webBrowser1.Navigate(urltemp); this.timer1.Start(); } else { indexExtract = 0; if (offsetindex < url.Count) { this.webBrowser1.Navigate(url[offsetindex]); urla = url[offsetindex]; conceptid = conceptidlist[offsetindex]; Console.WriteLine("offsetindex " + offsetindex); Console.WriteLine("conceptid " + conceptid); offsetindex++; this.timer1.Start(); } else { Application.Exit(); } } }
public void Test() { BaidudataEntities3 TDB = new BaidudataEntities3(); Instance tab = new Instance(); tab.conceptid = 1; tab.instance1 = "instance"; tab.instanceurl = "instanceurl"; TDB.Instance.Add(tab); TDB.SaveChanges(); }