Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        private void GetJiadian()
        {
            string content = htmlhelp.GetUniqTag(page, "div", "id=\"jinengjiadian\"");

            List <string> contents = htmlhelp.GetTagCollectByCharacter(content, "div", "class=\"styleContent\"");

            if (contents.Count() == 4)
            {
                ChangguiImage = htmlhelp.GetImgTagFromHtml(contents[0]);
                Changgui      = GetIntro(contents[0]);

                ChumenImage = htmlhelp.GetImgTagFromHtml(contents[1]);
                Chumen      = GetIntro(contents[1]);

                ZhongqiImage = htmlhelp.GetImgTagFromHtml(contents[2]);
                Zhongqi      = GetIntro(contents[2]);

                HouqiImage = htmlhelp.GetImgTagFromHtml(contents[3]);
                Houqi      = GetIntro(contents[3]);
            }
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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();
        }