Esempio n. 1
0
 private ArrayList GoogleParseItems(String sz_ResString)
 {
     ArrayList returnthingy = new ArrayList();
     String work_with_me = sz_ResString.Replace("<div class=g", "\n");
     String[] MyArray = work_with_me.Split('\n');
     // Now we have an array with length of n_length...
     foreach (String MyItm in MyArray)
     {
         if (MyItm != "")
         {
             String sz_UrlString = "";
             String sz_TitString = "";
             String sz_SnpString = "";
             String sz_CacString = "";
             bool b_titl = false;
             bool b_snip = false;
             String tmpitm = MyItm.Replace("<", "\n<");
             String[] tmparr = tmpitm.Split('\n');
             foreach (String newitm in tmparr)
             {
                 if (newitm.StartsWith("<a ") && sz_UrlString == "")
                 {
                     b_titl = true;
                     sz_UrlString = newitm;
                 }
                 else if (newitm.StartsWith("</a>"))
                 {
                     b_titl = false;
                 }
                 else if (newitm.StartsWith("<font size=-1>") && sz_SnpString == "")
                 {
                     b_snip = true;
                     sz_SnpString = newitm;
                 }
                 else if (newitm.StartsWith("<br>"))
                 {
                     b_snip = false;
                 }
                 else if (newitm.EndsWith(" - "))
                 {
                     sz_CacString = newitm;
                 }
                 else
                 {
                     if (b_snip) sz_SnpString += newitm;
                     if (b_titl) sz_TitString += newitm;
                 }
             }
             // We now have to clean and format the strings...
             sz_UrlString = sz_UrlString.Replace("<a href=\"", "");
             sz_UrlString = sz_UrlString.Replace("\" class=l onmousedown=\"return clk(this.href,'','','res','1','')\">", "");
             int n_moo = sz_UrlString.IndexOf("\"");
             if (n_moo > 0)
             {
                 sz_UrlString = sz_UrlString.Substring(0, n_moo);
             }
             //System.Diagnostics.Debug.WriteLine("Houston, I found URL : " + sz_UrlString);
             sz_SnpString = sz_SnpString.Replace("<font size=-1>", "");
             int n_c = sz_CacString.IndexOf(" - ");
             if (n_c > 0)
             {
                 String s_c = sz_CacString.Substring(n_c + 3, sz_CacString.Length - n_c - 3);
                 n_c = s_c.IndexOf(" - ");
                 if (n_c > 0)
                 {
                     s_c = s_c.Substring(0, n_c);
                 }
                 else
                 {
                     s_c = "";
                 }
                 sz_CacString = s_c;
             }
             else
             {
                 sz_CacString = "";
             }
             str_resitm tmp = new str_resitm();
             tmp.sz_url = sz_UrlString;
             tmp.sz_title = sz_TitString;
             tmp.sz_snip = sz_SnpString;
             tmp.sz_cache = sz_CacString;
             returnthingy.Add(tmp);
         }
     }
     return returnthingy;
 }
Esempio n. 2
0
        private ArrayList GoogleParseItems(String sz_ResString)
        {
            ArrayList returnthingy = new ArrayList();
            String    work_with_me = sz_ResString.Replace("<div class=g", "\n");

            String[] MyArray = work_with_me.Split('\n');
            // Now we have an array with length of n_length...
            foreach (String MyItm in MyArray)
            {
                if (MyItm != "")
                {
                    String   sz_UrlString = "";
                    String   sz_TitString = "";
                    String   sz_SnpString = "";
                    String   sz_CacString = "";
                    bool     b_titl       = false;
                    bool     b_snip       = false;
                    String   tmpitm       = MyItm.Replace("<", "\n<");
                    String[] tmparr       = tmpitm.Split('\n');
                    foreach (String newitm in tmparr)
                    {
                        if (newitm.StartsWith("<a ") && sz_UrlString == "")
                        {
                            b_titl       = true;
                            sz_UrlString = newitm;
                        }
                        else if (newitm.StartsWith("</a>"))
                        {
                            b_titl = false;
                        }
                        else if (newitm.StartsWith("<font size=-1>") && sz_SnpString == "")
                        {
                            b_snip       = true;
                            sz_SnpString = newitm;
                        }
                        else if (newitm.StartsWith("<br>"))
                        {
                            b_snip = false;
                        }
                        else if (newitm.EndsWith(" - "))
                        {
                            sz_CacString = newitm;
                        }
                        else
                        {
                            if (b_snip)
                            {
                                sz_SnpString += newitm;
                            }
                            if (b_titl)
                            {
                                sz_TitString += newitm;
                            }
                        }
                    }
                    // We now have to clean and format the strings...
                    sz_UrlString = sz_UrlString.Replace("<a href=\"", "");
                    sz_UrlString = sz_UrlString.Replace("\" class=l onmousedown=\"return clk(this.href,'','','res','1','')\">", "");
                    int n_moo = sz_UrlString.IndexOf("\"");
                    if (n_moo > 0)
                    {
                        sz_UrlString = sz_UrlString.Substring(0, n_moo);
                    }
                    //System.Diagnostics.Debug.WriteLine("Houston, I found URL : " + sz_UrlString);
                    sz_SnpString = sz_SnpString.Replace("<font size=-1>", "");
                    int n_c = sz_CacString.IndexOf(" - ");
                    if (n_c > 0)
                    {
                        String s_c = sz_CacString.Substring(n_c + 3, sz_CacString.Length - n_c - 3);
                        n_c = s_c.IndexOf(" - ");
                        if (n_c > 0)
                        {
                            s_c = s_c.Substring(0, n_c);
                        }
                        else
                        {
                            s_c = "";
                        }
                        sz_CacString = s_c;
                    }
                    else
                    {
                        sz_CacString = "";
                    }
                    str_resitm tmp = new str_resitm();
                    tmp.sz_url   = sz_UrlString;
                    tmp.sz_title = sz_TitString;
                    tmp.sz_snip  = sz_SnpString;
                    tmp.sz_cache = sz_CacString;
                    returnthingy.Add(tmp);
                }
            }
            return(returnthingy);
        }