Пример #1
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();
        }
Пример #2
0
        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);
            }
        }
Пример #3
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();
        }