Esempio n. 1
0
        internal static SearchObject SearchGoogle(string value)
        {
            //trans = Uri.UnescapeDataString(trans);


            value = value /*.Replace(" ", "+")*/.Replace("++", "+");
            if (hasNonAscisCaracter(value))
            {
                value = System.Uri.EscapeUriString(value);
            }

            string       url     = "https://www.google.com.eg/search?q=" + value + "&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr";
            string       pattern = "\"><h3 class=\"r\"><a href=\"";
            string       patrn2  = "><h3 class=\"r\"><a href=\"";
            string       ptr3    = "><h3 class=\"r\"><a href=\"";
            SearchObject res     = new SearchObject(value, pattern);

            res.ErrorMessage   = "Can not Search";
            res.ResponseObject = Requestor.Get(url, true);

            // checkSearch result
            if (res.ResponseObject.body.Contains(pattern) || res.ResponseObject.body.Contains(patrn2) || res.ResponseObject.body.Contains(ptr3))
            {
                res.SearchSucceeded = true;
                string masterPatrn = pattern;
                if (res.ResponseObject.body.Contains(pattern) == false)
                {
                    masterPatrn = patrn2;
                    if (res.ResponseObject.body.Contains(patrn2) == false)
                    {
                        masterPatrn = ptr3;
                    }
                }
                string[] arr = res.ResponseObject.body.Split(new string[] { masterPatrn }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string ax in arr)
                {
                    string a = ax.Trim();
                    if (a.StartsWith("http") == false)
                    {
                        continue;
                    }
                    else
                    {
                        if (a.Contains('"'))
                        {
                            a = a.Split('"')[0];
                        }
                    }
                    res.Searchlines.Add(a);
                    res.Success = true;
                }
            }
            return(res);
        }
Esempio n. 2
0
        private void Get()
        {
            /*
             *
             *
             * this.Invoke(new Loaddel(LoadResult), p);
             * */
            string       value = System.IO.File.ReadAllText(Application.StartupPath + "\\last");
            SearchObject obj   = Requestor.SearchGoogle(value);

            while (obj.SearchSucceeded == false && obj.Success)
            {
                obj = Requestor.SearchGoogle(value);
            }
            if (obj.Searchlines.Count < 3 - 2 || obj.Success == false)
            {
                MessageBox.Show(obj.ErrorMessageFriendly(), "Error");
            }
            else
            {
                if (obj.Searchlines.Count < 3 - 2)
                {
                    MessageBox.Show("search returned 0 result");
                }

                else if (Requestor.IsSupporttedWebsite(obj.Searchlines) == false)
                {
                    MessageBox.Show("Can not proceed with received websites from " + obj.SearchMethod + " result");

                    this.Invoke(new Loaddel(LoadResult), obj.SearchlinesTostring());
                }
                else
                {
                    FinalData result = new FinalData("");
                    bool      got    = false;
                    string    fox    = "";

                    fox = "Searching links\n";
                    foreach (string g in obj.Searchlines)
                    {
                        fox += g + "\n";
                    }
                    this.Invoke(new Loaddel(LoadResult), fox);

                    foreach (string l in obj.Searchlines)
                    {
                        if (got)
                        {
                            break;
                        }
                        if (Requestor.IsSupporttedWebsite(l) == false)
                        {
                            continue;
                        }
                        result = Requestor.ProcessCima4U(l);

                        if (result.HasData())
                        {
                            if (result.DownloadList.Count > 0)
                            {
                                fox = "\nDownload Links \n";
                                foreach (string xl in result.DownloadList)
                                {
                                    fox += xl + "\n";
                                }
                                this.Invoke(new Loaddel(LoadResult), fox);
                                System.Threading.Thread.Sleep(999);
                            }
                            if (result.WatchList.Count > 0)
                            {
                                fox = "\nWatching Links \n";

                                foreach (string xl in result.WatchList)
                                {
                                    fox += xl + "\n";
                                }
                                if (result.WatchList.Count > 0)
                                {
                                    this.Invoke(new Loaddel(LoadResult), fox);
                                }
                            }
                            if (result.DirectStreamList.Count > 0)
                            {
                                fox = "\nDirect Download Links \n";

                                foreach (string xl in result.DirectStreamList)
                                {
                                    fox += xl + "\n";
                                }

                                this.Invoke(new Loaddel(LoadResult), fox);
                                System.Threading.Thread.Sleep(999);
                            }
                            got = true;
                        }
                        else if (result.Success == false)
                        {
                            fox = result.ResponseData.ResponseErrorMessage + " " + result.ResponseData.ErrorUrl;
                        }
                    }


                    //if (got)
                    //    this.Invoke(new Loaddel(LoadResult), result);
                }
            }
            Load_Poster(true);
            try{ this.Invoke(new ActiveDel(ActivateButton)); }catch {}
        }