Example #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();
        }
Example #2
0
        private static void jiengImage(string link)
        {
            HtmlHelp   htmlHelp = new HtmlHelp();
            string     htmlStr  = htmlHelp.DownloadPage(link);
            SingleHero singHero = new SingleHero(htmlStr);

            //string gif1 = singHero.Image;
            //int start1 = gif1.LastIndexOf('/');
            //int length1 = gif1.Length - start1;
            //string name1 = gif1.Substring(start1 + 1);
            //Console.WriteLine(name1.Substring(0, name1.Length - 4) + ".png");
            //htmlHelp.DownloadImgae("", singHero.Image);
            //htmlHelp.DownloadImgae(@"D:\Dota\Avatars\" + name1.Substring(0, name1.Length - 4) + ".png", singHero.Image);
            //try
            //{
            //    System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\Avatars\" + name1.Substring(0, name1.Length - 4) + ".png");
            //    imgFile.Save(@"D:\Dota\Avatars1\" + name1.Substring(0, name1.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png);
            //}
            //catch
            //{
            //    Console.WriteLine(singHero.Image);
            //}
            foreach (Jineng item in singHero.list_Jienng)
            {
                string gif    = item.Image;
                int    start  = gif.LastIndexOf('/');
                int    length = gif.Length - start;
                string name   = gif.Substring(start + 1);
                Console.WriteLine(name.Substring(0, name.Length - 4) + ".png");
                try
                {
                    System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\JiNengs\" + name.Substring(0, name.Length - 4) + ".png");
                    imgFile.Save(@"D:\Dota\JiNengs1\" + name.Substring(0, name.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png);
                }
                catch
                {
                    Console.WriteLine(gif);
                }
                // htmlHelp.DownloadImgae(@"D:\Dota\JiNengs\" + name.Substring(0, name.Length - 4) + ".png", gif);
                // htmlHelp.DownloadImgae("", item.Image);
            }
            Console.WriteLine("       ");
            //Console.ReadLine();
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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();
        }
Example #5
0
        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();
            }
        }
Example #6
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();
        }
Example #7
0
        public void DownloadImage(string path, string src)
        {
            HtmlHelp htmlhelp = new HtmlHelp();

            htmlhelp.DownloadImgae(path, src);
        }
Example #8
0
 public void DownloadImage(string path, string src)
 {
     HtmlHelp htmlhelp = new HtmlHelp();
     htmlhelp.DownloadImgae(path, src);
 }
Example #9
0
        private static void jiengImage(string link)
        {
            HtmlHelp htmlHelp = new HtmlHelp();
            string htmlStr=htmlHelp.DownloadPage(link);
            SingleHero singHero = new SingleHero(htmlStr);
            //string gif1 = singHero.Image;
            //int start1 = gif1.LastIndexOf('/');
            //int length1 = gif1.Length - start1;
            //string name1 = gif1.Substring(start1 + 1);
            //Console.WriteLine(name1.Substring(0, name1.Length - 4) + ".png");
            //htmlHelp.DownloadImgae("", singHero.Image);
            //htmlHelp.DownloadImgae(@"D:\Dota\Avatars\" + name1.Substring(0, name1.Length - 4) + ".png", singHero.Image);
            //try
            //{
            //    System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\Avatars\" + name1.Substring(0, name1.Length - 4) + ".png");
            //    imgFile.Save(@"D:\Dota\Avatars1\" + name1.Substring(0, name1.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png);
            //}
            //catch
            //{
            //    Console.WriteLine(singHero.Image);
            //}
            foreach (Jineng item in singHero.list_Jienng)
            {
                string gif = item.Image;
                int start = gif.LastIndexOf('/');
                int length = gif.Length - start;
                string name = gif.Substring(start + 1);
                Console.WriteLine(name.Substring(0, name.Length - 4) + ".png");
                try
                {
                    System.Drawing.Image imgFile = System.Drawing.Image.FromFile(@"D:\Dota\JiNengs\" + name.Substring(0, name.Length - 4) + ".png");
                    imgFile.Save(@"D:\Dota\JiNengs1\" + name.Substring(0, name.Length - 4) + ".png", System.Drawing.Imaging.ImageFormat.Png);
                }
                catch
                {
                    Console.WriteLine(gif);
                }
               // htmlHelp.DownloadImgae(@"D:\Dota\JiNengs\" + name.Substring(0, name.Length - 4) + ".png", gif);
                // htmlHelp.DownloadImgae("", item.Image);

            }
            Console.WriteLine("       ");
            //Console.ReadLine();
        }
Example #10
0
        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();
        }
Example #11
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();
        }
Example #12
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();
        }