public void DownloadPage() { string link = "http://dota.sgamer.com/hero/"; string deskfile = "3.txt"; FileStream afile = new FileStream(@"D:\Dota\" + deskfile, FileMode.Create); StreamWriter writer = new StreamWriter(afile); HtmlHelp htmlhelp = new HtmlHelp(); string dotapage = htmlhelp.DownloadPage(link); string heropart = htmlhelp.GetUniqTag(dotapage, "div", "class=\"BG_Block\""); List <string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", ""); // get all heros data foreach (var item in allheros) { Hero hero = new Hero(item); writer.WriteLine(hero.Alt + ";" + hero.Src + ";" + hero.Href); } if (writer != null) { writer.Close(); } if (afile != null) { afile.Close(); } Console.WriteLine("end..."); Console.ReadLine(); }
public void DownloadPage(string link) { string deskfile = "3.txt"; FileStream afile = new FileStream(@"D:\Dota\" + deskfile, FileMode.Create); StreamWriter writer = new StreamWriter(afile); HtmlHelp htmlhelp = new HtmlHelp(); string page=htmlhelp.DownloadPage(link); string main = htmlhelp.GetUniqTag(page, "div", ""); if (writer != null) { writer.Close(); } if (afile != null) { afile.Close(); } }
private static void itemImage() { string link = "http://dota.sgamer.com/item/"; HtmlHelp htmlhelp = new HtmlHelp(); string htmlStr = htmlhelp.DownloadPage(link); string str = htmlhelp.GetUniqTag(htmlStr, "div", "Class=\"BG_Block\""); List <string> contents = htmlhelp.GetImgTagFromHtml1(str); int i = 0; foreach (string s in contents) { i++; Console.WriteLine(i); string gif = GetContent(s, "src"); int start = gif.LastIndexOf('/'); int length = gif.Length - start; string name = gif.Substring(start + 1); // string name1 = " /Avatar/" + name.Substring(0, name.Length - 4) + ".png"; // htmlhelp.DownloadImgae(@"D:\Dota\Items\" + name.Substring(0, name.Length - 4) + ".png", gif); try { System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\Items\" + name.Substring(0, name.Length - 4) + ".png"); imgFile.Save(@"D:\Dota\Items1\" + name.Substring(0, name.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png); } catch { Console.WriteLine(gif); } Console.WriteLine(name.Substring(0, name.Length - 4) + ".png"); //Regex regex = new Regex("[0-9]{2,6}"); //Match match = regex.Match(GetContent(s, "onmouseover")); //if (match.Success) //{ // // item.DetailId = match.Value; // // htmlhelp.DownloadPage("http://cms1.sgamer.com/Ajax/DisplayDOTAItem?callback=?&itemID=" + match.Value, callback); //} } Console.WriteLine("end...."); Console.ReadLine(); }
public ItemsClass(string htmlStr) { string str = htmlhelp.GetUniqTag(htmlStr, "div", "Class=\"BG_Block\""); List <string> contents = htmlhelp.GetImgTagFromHtml1(str); foreach (string s in contents) { AvatarUri = GetContent(s, "src"); Regex regex = new Regex("[0-9]{2,6}"); Match match = regex.Match(GetContent(s, "onmouseover")); //if (match.Success) //{ // // Console.WriteLine(match.Value); // string detail = htmlhelp.DownloadPage("http://cms1.sgamer.com/Ajax/DisplayDOTAItem?callback=?&itemID="+match.Value); // detail = detail.Substring(2, s.Length - 3); // Detail = detail; //} Console.WriteLine(AvatarUri); //Console.WriteLine(Detail); } }
public void DownloadPage(string link) { string deskfile = "3.txt"; FileStream afile = new FileStream(@"D:\Dota\" + deskfile, FileMode.Create); StreamWriter writer = new StreamWriter(afile); HtmlHelp htmlhelp = new HtmlHelp(); string page = htmlhelp.DownloadPage(link); string main = htmlhelp.GetUniqTag(page, "div", ""); if (writer != null) { writer.Close(); } if (afile != null) { afile.Close(); } }
private static void heroImage() { string link = "http://dota.sgamer.com/hero/"; HtmlHelp htmlhelp = new HtmlHelp(); string htmlStr = htmlhelp.DownloadPage(link); string heropart = htmlhelp.GetUniqTag(htmlStr, "div", "class=\"BG_Block\""); List <string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", ""); int i = 0; foreach (var item in allheros) { i++; Console.WriteLine(i); if (i == 17) { Hero hero = new Hero(item); jiengImage(hero.Href); } //string gif = hero.Src; //int start = gif.LastIndexOf('/'); //int length = gif.Length - start; //string name = gif.Substring(start + 1); //try //{ // System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\Heros\" + name.Substring(0, name.Length - 4) + ".png"); // imgFile.Save(@"D:\Dota\Heros1\" + name.Substring(0, name.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png); //} //catch //{ // Console.WriteLine(gif); //} //// string name1 = " /Avatar/" + name.Substring(0, name.Length - 4) + ".png"; ////htmlhelp.DownloadImgae(@"D:\Dota\Heros\" + name.Substring(0, name.Length - 4) + ".png", gif); //Console.WriteLine(name.Substring(0, name.Length - 4) + ".png"); } Console.WriteLine("end...."); Console.ReadLine(); }
private void GetImage() { string content = htmlhelp.GetUniqTag(page, "div", "class=\"H_pic1\""); Image = GetContent(content, "src"); }
private static void itemImage() { string link= "http://dota.sgamer.com/item/"; HtmlHelp htmlhelp = new HtmlHelp(); string htmlStr=htmlhelp.DownloadPage(link); string str = htmlhelp.GetUniqTag(htmlStr, "div", "Class=\"BG_Block\""); List<string> contents = htmlhelp.GetImgTagFromHtml1(str); int i = 0; foreach (string s in contents) { i++; Console.WriteLine(i); string gif=GetContent(s, "src"); int start = gif.LastIndexOf('/'); int length = gif.Length - start; string name = gif.Substring(start + 1); // string name1 = " /Avatar/" + name.Substring(0, name.Length - 4) + ".png"; // htmlhelp.DownloadImgae(@"D:\Dota\Items\" + name.Substring(0, name.Length - 4) + ".png", gif); try { System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\Items\" + name.Substring(0, name.Length - 4) + ".png"); imgFile.Save(@"D:\Dota\Items1\" + name.Substring(0, name.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png); } catch { Console.WriteLine(gif); } Console.WriteLine(name.Substring(0, name.Length - 4) + ".png"); //Regex regex = new Regex("[0-9]{2,6}"); //Match match = regex.Match(GetContent(s, "onmouseover")); //if (match.Success) //{ // // item.DetailId = match.Value; // // htmlhelp.DownloadPage("http://cms1.sgamer.com/Ajax/DisplayDOTAItem?callback=?&itemID=" + match.Value, callback); //} } Console.WriteLine("end...."); Console.ReadLine(); }
private static void heroImage() { string link= "http://dota.sgamer.com/hero/"; HtmlHelp htmlhelp = new HtmlHelp(); string htmlStr=htmlhelp.DownloadPage(link); string heropart = htmlhelp.GetUniqTag(htmlStr, "div", "class=\"BG_Block\""); List<string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", ""); int i=0; foreach (var item in allheros) { i++; Console.WriteLine(i); if (i ==17) { Hero hero = new Hero(item); jiengImage(hero.Href); } //string gif = hero.Src; //int start = gif.LastIndexOf('/'); //int length = gif.Length - start; //string name = gif.Substring(start + 1); //try //{ // System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\Heros\" + name.Substring(0, name.Length - 4) + ".png"); // imgFile.Save(@"D:\Dota\Heros1\" + name.Substring(0, name.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png); //} //catch //{ // Console.WriteLine(gif); //} //// string name1 = " /Avatar/" + name.Substring(0, name.Length - 4) + ".png"; ////htmlhelp.DownloadImgae(@"D:\Dota\Heros\" + name.Substring(0, name.Length - 4) + ".png", gif); //Console.WriteLine(name.Substring(0, name.Length - 4) + ".png"); } Console.WriteLine("end...."); Console.ReadLine(); }
public void DownloadPage() { string link = "http://dota.sgamer.com/hero/"; string deskfile = "3.txt"; FileStream afile = new FileStream(@"D:\Dota\" + deskfile, FileMode.Create); StreamWriter writer = new StreamWriter(afile); HtmlHelp htmlhelp = new HtmlHelp(); string dotapage = htmlhelp.DownloadPage(link); string heropart = htmlhelp.GetUniqTag(dotapage, "div", "class=\"BG_Block\""); List<string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", ""); // get all heros data foreach (var item in allheros) { Hero hero = new Hero(item); writer.WriteLine(hero.Alt + ";" + hero.Src + ";" + hero.Href); } if (writer != null) { writer.Close(); } if (afile != null) { afile.Close(); } Console.WriteLine("end..."); Console.ReadLine(); }