Is there a more efficient way to get the number of search results from a google query?

Posted by highone on Stack Overflow See other posts from Stack Overflow or by highone
Published on 2010-02-14T00:24:23Z Indexed on 2010/04/14 0:43 UTC
Read the original article Hit count: 336

Filed under:
|
|

Right now I am using this code:

string url = "http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=hey&esrch=FT1";
            string source = getPageSource(url);
            string[] stringSeparators = new string[] { "<b>", "</b>" };
            string[] b = source.Split(stringSeparators, StringSplitOptions.None);
            bool isResultNum = false;
            foreach (string s in b)
            {
                if (isResultNum)
                {
                    MessageBox.Show(s.Replace(",", ""));
                    return;
                }
                if (s.Contains(" of about "))
                {
                    isResultNum = true;
                }
            }

Unfortunately it is very slow, is there a better way to do it? Also is it legal to query google like this? From the answer in this question it didn't sound like it was http://stackoverflow.com/questions/903747/how-to-download-google-search-results

© Stack Overflow or respective owner

Related posts about c#

Related posts about c#4.0