Exemplo n.º 1
0
        private static List <GISResult> GetImagesFromGoogle(string html)
        {
            var urlList = new List <GISResult>();

            var imagesRegex = new Regex(@"dyn\.Img\(\""(?<url>.*?)\"",\""(?<ignore>.*?)\"",\""(?<googleID>.*?)\"",\""(?<img>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<size>.*?)\""");

            //Regex imagesRegex = new Regex(@"(\x3Ca\s+href=/imgres\" +
            //           @"x3Fimgurl=)(?<imgurl>http" +
            //           @"[^&>]*)([>&]{1})" +
            //           @"([^>]*)(>{1})(<img\ssrc\" +
            //           @"x3D)(""{0,1})(?<images>/images" +
            //           @"[^""\s>]*)([\s])+(width=)" +
            //           @"(?<width>[0-9,]*)\s+(height=)" +
            //           @"(?<height>[0-9,]*)");
            //Regex dataRegex = new Regex(@"([^>]*)(>)\s{0,1}(<br>){0,1}\s{0,1}" +
            //         @"(?<width>[0-9,]*)\s+x\s+(?<height>[0-9,]*)" +
            //         @"\s+pixels\s+-\s+(?<size>[0-9,]*)(k)");

            MatchCollection images = imagesRegex.Matches(html);
            //MatchCollection data = dataRegex.Matches(html);
            int i = 0;

            foreach (Match m in images)
            {
                var result = new GISResult();
                result.ThumbURL = "http://images.google.com/images?q=tbn:" + m.Groups["googleID"].Value + m.Groups["img"].Value;
                result.OrigURL  = m.Groups["img"].Value;
                result.OrigSize = m.Groups["size"].Value;
                urlList.Add(result);
                i++;
            }

            return(urlList);
        }
Exemplo n.º 2
0
        private void AddPicture(GISResult s, Image pct)
        {
            var pic = new PictureBox
            {
                Tag       = s,
                SizeMode  = PictureBoxSizeMode.AutoSize,
                BackColor = Color.Black,
                Padding   = new Padding(1),
                Image     = pct
            };

            pic.MouseDown += new MouseEventHandler(pic_MouseDown);
            toolTip1.SetToolTip(pic, "URL: " + s.OrigURL + "\nThumbnail Size: " + pct.Width + " x " + pct.Height + "\nFull Size: " + s.OrigSize);
            flowLayoutPanel1.BeginInvoke(new MethodInvoker(delegate
            {
                flowLayoutPanel1.Controls.Add(pic);
            }));
        }
Exemplo n.º 3
0
        private static List <GISResult> GetImagesFromGoogle(string html)
        {
            var urlList = new List <GISResult>();

            Regex imagesRegex = new Regex(@"dyn\.Img\(\""(?<url>.*?)\"",\""(?<ignore>.*?)\"",\""(?<googleID>.*?)\"",\""(?<img>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<ignore>.*?)\"",\""(?<size>.*?)\""");

            string titleRegex = @"([^>]*)(>)\s{0,1}(<br>){0,1}\s{0,1}";

            MatchCollection images = imagesRegex.Matches(html);
            int             i      = 0;

            foreach (Match m in images)
            {
                var result = new GISResult();
                result.ThumbURL = "http://images.google.com/images?q=tbn:" + m.Groups["googleID"].Value + m.Groups["img"].Value;
                result.OrigURL  = m.Groups["img"].Value;
                result.OrigSize = m.Groups["size"].Value;
                urlList.Add(result);
                i++;
            }
            titleRegex.ToString();
            return(urlList);
        }