Ejemplo n.º 1
0
        public string PrintCollection(ArrayList xcollection, string Searchurl)
        {
            string Date = null;

            richTextBox1.Text += "\n\n-----------Output Box--------------\n";
            foreach (var x in xcollection)
            {
                GoogleResult result = (GoogleResult)x;
                richTextBox1.Text += "Google Record....\n Title=" + result.Title + " \n  Link= " + result.Link + "\n Date= " + result.Date + "\n\n";
                if (CompareStrings(result.Link, Searchurl))
                {
                    Date = result.Date;
                }
            }
            richTextBox1.Text += "\n\n-----------------------------------\n";
            return(Date);
        }
Ejemplo n.º 2
0
        private void CheckInBase(HtmlElement element)
        {
            richTextBox1.Text += "\n\n--------Base---------\n\n";
            GoogleResult result       = new GoogleResult();
            string       ResultString = null;

            try
            {
                #region Link

                MatchCollection collection = Regex.Matches(element.InnerHtml, "<a onmousedown=\"return.*?href=\"(?<data>.*?)\">",
                                                           RegexOptions.Multiline);

                foreach (Match m in collection)
                {
                    ResultString = m.Groups["data"].Value;
                    if (ResultString.Contains("cache") == false && ResultString.Contains("#") == false && ResultString.Contains("site") == false)
                    {
                        if (ResultString.Contains("search?q=related"))
                        {
                            return;
                        }
                        else
                        {
                            result.Link        = ResultString;
                            richTextBox1.Text += "\n\nLink=" + result.Link + "\n\n";
                        }
                    }
                }
                #endregion
                #region title
                collection = Regex.Matches(element.InnerHtml, @"<h3.*?<a onmousedown=.*?>(?<data>.*?)</a></h3>",
                                           RegexOptions.Multiline);

                foreach (Match m in collection)
                {
                    ResultString = m.Groups["data"].Value;
                    if (ResultString.Contains("cache") == false && String.IsNullOrEmpty(ResultString) == false)
                    {
                        result.Title       = ResultString;
                        richTextBox1.Text += "\n\nTitle=" + ResultString + "\n\n";
                    }
                }
                #endregion
                #region Date
                collection = Regex.Matches(element.InnerHtml, "<span class=\"f\">(?<data>.*?)</span>",
                                           RegexOptions.Multiline);

                foreach (Match m in collection)
                {
                    ResultString       = m.Groups["data"].Value;
                    richTextBox1.Text += "\n\nDate=" + ResultString + "\n\n";
                    result.Date        = ResultString;
                }
                #endregion
            }
            catch (ArgumentException ex)
            {
                throw new Exception("While Reading Google Record" + ex.Message);
            }
            richTextBox1.Text += "\n\n--------Base Ends---------\n\n";

            #region Add in List
            bool AlreadyExist = false;
            foreach (object x in RecordList)
            {
                GoogleResult TempCheckObj = (GoogleResult)x;
                if (TempCheckObj.Link.Equals(result.Link))
                {
                    AlreadyExist = true;
                }
            }
            if (AlreadyExist == false)
            {
                RecordList.Add(result);
            }
            #endregion
        }