Get Value In Between Other Values / Get Value between HTML Tags

Used this on Black Friday 2010 to scrape Buy.com’s site for a Plasma deal.


        public void CheckPrice()
        {

            try
            {
                string buyDotComRawScrapeInput = GetScreenScrape("http://www.buy.com/prod/panasonic-tc-p42u2-42-widescreen-1080p-plasma-hdtv-2-000-000-1/q/loc/111/214680105.html");

                string start = @"<span id=""spanMainTotalPrice"" style=""font-size:16px; font-weight:bold;"">";
                string end = "</span>";

                int startNum = buyDotComRawScrapeInput.IndexOf(start);
                int endNum = buyDotComRawScrapeInput.IndexOf(end, startNum);

                string result = buyDotComRawScrapeInput.Substring(startNum + start.Length, endNum - startNum - start.Length);

                if (!string.IsNullOrEmpty(result))
                {
                    if (float.Parse(result) < 450)
                    {
                        // Price is under $400 lets alert!
                        System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
                        myPlayer.SoundLocation = @"c:\windows\media\notify.wav";
                        myPlayer.PlayLooping();

                        SendEmail(result);

                        timer1.Enabled = false;

                    }
                }
            }
            catch (Exception)
            {


            }


        }