Beispiel #1
0
        public void LoadAnimeList(bool needSynopsis = false)
        {
            var width = EpisodesFlowPanel.Width;

            EpisodesFlowPanel.Controls.Clear();
            AnimeSynopsis.Text = CleanSynopsis(AnimeSynopsis.Text);

            _phantomObject.Navigate().GoToUrl(AnimeUrl);
            if (needSynopsis)
            {
                AnimeSynopsis.Text = CleanSynopsis(_phantomObject.FindElementsByTagName("p")[2].Text);
            }
            var myTable = _phantomObject.FindElementsByClassName("episode");

            foreach (var node in myTable)
            {
                var epcontrol = new EpisodeControl
                {
                    Text = node.Text.Trim(),
                    Tag  = node.GetAttribute("data-value")
                };
                if (StaticsClass.MyAnimeListObject != null)
                {
                    epcontrol.RateIcon.Click += RateIcon_Click;
                }
                else
                {
                    epcontrol.RateIcon.Visible = false;
                }
                EpisodesFlowPanel.Controls.Add(epcontrol);
                EpisodesFlowPanel.Controls.SetChildIndex(epcontrol, 0);
            }
            BringToFront();
        }
Beispiel #2
0
        /// <summary>
        /// Método responsável por retornar os funcionarios da empresa selecionada
        /// </summary>
        /// <param name="poPhantom">Objeto phantomjsdriver</param>
        /// <param name="pstrCode">Codigo da empresa</param>
        /// <returns></returns>
        public static List <LinkedinUser> GetPeoples(PhantomJSDriver poPhantom, string pstrCode)
        {
            var pageCount = 5;
            var loModel   = new List <LinkedinUser>();
            var url       = $"https://www.linkedin.com/search/results/people/?facetCurrentCompany=%5B\"{pstrCode}\"%5D";

            for (int lintCont = 1; lintCont <= pageCount; lintCont++)
            {
                poPhantom.Navigate().GoToUrl($"{url}&page={lintCont}");

                var users = poPhantom.FindElementsByClassName("search-result__wrapper");

                for (int lintCont2 = 0; lintCont2 < users.Count; lintCont2++)
                {
                    var model = new LinkedinUser();

                    model.Name  = users[lintCont2].FindElement(By.ClassName("actor-name")).Text;
                    model.Foto  = users[lintCont2].FindElement(By.TagName("img")).GetAttribute("src");
                    model.Cargo = users[lintCont2].FindElement(By.ClassName("subline-level-1")).Text;
                    model.Link  = users[lintCont2].FindElement(By.ClassName("search-result__result-link")).GetAttribute("href");

                    loModel.Add(model);
                }
            }

            return(loModel);
        }
Beispiel #3
0
        public ActionResult Index(SearchRequest req)
        {
            var list = new List <Item>();

            try
            {
                var driver = new PhantomJSDriver();
                driver.Navigate().GoToUrl($"https://www.google.se/#q={req.Query}");
                var elements = driver.FindElementsByClassName("g");

                foreach (var element in elements)
                {
                    var link   = element.FindElement(By.TagName("a")).GetAttribute("href");
                    var header = element.FindElement(By.TagName("h3")).Text;
                    list.Add(new Item
                    {
                        Header = header,
                        Url    = link
                    });
                }
            }
            catch (Exception e)
            {
            }

            return(this.Json(new Result
            {
                Query = req.Query,
                Items = list.ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var list = new List <SearchResultController.Item>();

            try
            {
                var driver = new PhantomJSDriver();
                driver.Navigate().GoToUrl($"https://www.google.se/#q={Request.QueryString["query"]}");
                var elements = driver.FindElementsByClassName("g");

                foreach (var element in elements)
                {
                    var link   = element.FindElement(By.TagName("a")).GetAttribute("href");
                    var header = element.FindElement(By.TagName("h3")).Text;
                    list.Add(new SearchResultController.Item
                    {
                        Header = header,
                        Url    = link
                    });
                }
            }
            catch (Exception)
            {
            }

            Pling = "{ \"Query\": \"" + Request.QueryString["Query"] + "\", \"Items\": []}";
        }
Beispiel #5
0
        public static void GetPageSource(string username)
        {
            user = new User();

            var driverService = PhantomJSDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            Driver     = new PhantomJSDriver(driverService);
            Driver.Url = BASE_PATH + username + "/";
            Driver.Navigate();

            try
            {
                user.Name = Driver.FindElementByClassName("rhpdm").Text;
            }
            catch (NoSuchElementException) { }

            try
            {
                user.About = Driver.FindElementByClassName("vDIg").FindElement(By.TagName("span")).Text;
            }
            catch (NoSuchElementException) { }

            try
            {
                user.Ref = Driver.FindElementByClassName("yLUwa").Text;
            }
            catch (NoSuchElementException) { }

            try
            {
                user.Avatar = Driver.FindElementByClassName("_6q-tv").GetAttribute("src"); // ссылка на аву
            }
            catch (NoSuchElementException) { }

            try
            {
                var listPhotos = Driver.FindElementsByClassName("v1Nh3");

                List <string> listUrlPhotos = new List <string>();

                foreach (var photo in listPhotos)
                {
                    var url = photo.FindElement(By.TagName("a")).GetAttribute("href");
                    listUrlPhotos.Add(url);
                }

                foreach (var urlPhoto in listUrlPhotos)
                {
                    setInfoPhoto(urlPhoto);
                }
            }
            catch (NoSuchElementException) { }

            Console.WriteLine(user.ToString());
            Driver.Close();
            Driver.Quit();
        }
Beispiel #6
0
        private ReadOnlyCollection <IWebElement> GetMatchesList(string url)
        {
            ReadOnlyCollection <IWebElement> matchesNotStarted = null;

            JSDriver.Url = url;
            JSDriver.Navigate();

            string content = JSDriver.PageSource;

            matchesNotStarted = JSDriver.FindElementsByClassName("stage-scheduled"); // only get matches that already started
            return(matchesNotStarted);
        }
        public void LoadAnimeList(bool needSynopsis = false)
        {
            var width = EpisodesFlowPanel.Width;

            EpisodesFlowPanel.Controls.Clear();
            AnimeSynopsis.Text = CleanSynopsis(AnimeSynopsis.Text);

            var splitData = AnimeUrl.Split('/');

            splitData[splitData.Length - 1] = System.Web.HttpUtility.UrlEncode(splitData.Last(), System.Text.Encoding.UTF8);
            AnimeUrl = string.Join("/", splitData);

            _phantomObject.Navigate().GoToUrl(AnimeUrl);
            if (needSynopsis)
            {
                AnimeSynopsis.Text = CleanSynopsis(_phantomObject.FindElementsByTagName("p")[2].Text);
            }
            var myTable = _phantomObject.FindElementsByClassName("episode");

            foreach (var node in myTable)
            {
                var epcontrol = new EpisodeControl
                {
                    Text = node.Text.Trim(),
                    Tag  = node.GetAttribute("data-value")
                };
                if (StaticsClass.MyAnimeListObject != null)
                {
                    epcontrol.RateIcon.Click += RateIcon_Click;
                }
                else
                {
                    epcontrol.RateIcon.Visible = false;
                }
                EpisodesFlowPanel.Controls.Add(epcontrol);
                EpisodesFlowPanel.Controls.SetChildIndex(epcontrol, 0);
            }
            BringToFront();
        }
Beispiel #8
0
        public AccountDetail GetAccountDetails()
        {
            if (driver != null)
            {
                string   abc  = string.Empty;
                Document body = null;
                ReadOnlyCollection <IWebElement> alltables;
                try
                {
                    driver.SwitchTo().Window(driver.CurrentWindowHandle);
                    driver.SwitchTo().Frame("frame_menu");
                    driver.FindElementById("RRADTlink").Click();

                    driver.SwitchTo().Window(driver.CurrentWindowHandle);
                    driver.SwitchTo().Frame("frame_txn");

                    SelectElement elem = new SelectElement(driver.FindElementById("fldacctnodesc"));
                    elem.SelectByValue(this.Value);

                    driver.FindElementByName("fldsubmit").Click();

                    alltables = driver.FindElementsByClassName("infotable");
                    abc       = alltables[0].GetAttribute("innerHTML");
                    body      = Supremes.Dcsoup.Parse(abc);
                }
                catch
                {
                    throw new Exception("(ErrorCode:6) Service Or Network not Available Or Might be Some Rendering Problem Try again.");
                }

                AccountDetail detail = new AccountDetail(this.Value, driver);
                detail.AccountTitle  = body.Body.TextNodes[1].Text;
                detail.AccountNumber = body.Body.TextNodes[4].Text;

                abc  = alltables[2].GetAttribute("innerHTML");
                body = Supremes.Dcsoup.Parse(abc);

                detail.CurrentBalance   = Convert.ToDouble(body.Body.TextNodes[2].Text.Replace(",", ""));
                detail.AmountOnHold     = Convert.ToDouble(body.Body.TextNodes[4].Text.Replace(",", ""));
                detail.UnClearedFunds   = Convert.ToDouble(body.Body.TextNodes[6].Text.Replace(",", ""));
                detail.OverDraftLimit   = Convert.ToDouble(body.Body.TextNodes[8].Text.Replace(",", ""));
                detail.AvailableBalance = Convert.ToDouble(body.Body.TextNodes[10].Text.Replace(",", ""));
                detail.NetAvailableBalanceForWithDrawls = Convert.ToDouble(body.Body.TextNodes[12].Text.Replace(",", ""));

                return(detail);
            }
            else
            {
                throw new Exception("(ErrorCode:5) Account object not initialized");
            }
        }
Beispiel #9
0
        private IReadOnlyCollection <IWebElement> GetElements()
        {
            var response = new ReadOnlyCollection <IWebElement>(new List <IWebElement>());

            using (var driver = new PhantomJSDriver())
            {
                driver.Navigate().GoToUrl(url);

                var pageSource = driver.PageSource;
                Thread.Sleep(5000);
                var newPageSource = driver.PageSource;
                var htmlDoc       = new HtmlDocument();
                htmlDoc.LoadHtml(driver.PageSource);
                htmlDocuments.Add(htmlDoc);

                response = driver.FindElementsByClassName(groups);
                driver.Quit();
            }
            return(response);
        }
Beispiel #10
0
        /// <summary>
        /// get the results from the search and display them in the console
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="wait"></param>
        public void DisplayResults(PhantomJSDriver driver, WebDriverWait wait)
        {
            try
            {
                Console.WriteLine("Input a Number to select Product:");

                var ResultsLinks = new List <IWebElement>();
                ResultsLinks.AddRange(driver.FindElementsByClassName("product_title"));

                int ProductIndex = 0;
                foreach (var Product in ResultsLinks)
                {
                    Console.WriteLine("Product " + ProductIndex + Product.Text);
                    ProductIndex++;
                }

                var ProductIndexSelected = Console.ReadLine();


                if (ProductIndexSelected != null || ProductIndexSelected != string.Empty)
                {
                    if (Int32.Parse(ProductIndexSelected) > ProductIndex)
                    {
                        Console.WriteLine("Index Not Valid");
                    }
                    else
                    {
                        var href = ResultsLinks[Int32.Parse(ProductIndexSelected)].FindElement(By.TagName("a")).GetAttribute("href");
                        driver.Navigate().GoToUrl(href);
                    }
                }
                else
                {
                    Console.WriteLine("No Index Selected");
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine("Display Results Failed : " + Ex.Message);
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("SoloLearn username password");
                Environment.Exit(1);
            }

            string userName = args[0];
            string passWord = args[1];

            Dictionary <string, int> countries = GetCountries();

            var driver = new PhantomJSDriver();

            driver.Navigate().GoToUrl(loginUrl);
            var userID = driver.FindElementById("Email");

            userID.Clear();
            userID.SendKeys(userName);
            var passID = driver.FindElementById("Password");

            passID.Clear();
            passID.SendKeys(passWord);

            var form = driver.FindElementByTagName("form");

            form.Submit();

            driver.Navigate().GoToUrl(scrapeUrl);

            int delay = 3000; // 3 seconds
            var javascriptInBrowser     = (IJavaScriptExecutor)driver;
            var detailsWrapper          = driver.FindElementsByClassName("detailsWrapper");
            var lastDetailsWrapperCount = detailsWrapper.Count;

            while (true)
            {
                javascriptInBrowser.ExecuteScript("arguments[0].scrollIntoView(true);",
                                                  detailsWrapper[lastDetailsWrapperCount - 1]);
                Thread.Sleep(delay);
                detailsWrapper = driver.FindElementsByClassName("detailsWrapper");
                if (detailsWrapper.Count == lastDetailsWrapperCount)
                {
                    break;
                }
                else
                {
                    lastDetailsWrapperCount = detailsWrapper.Count;
                    delay += 500; // add 1/2 a second to the delay
                }
            }
            string text = string.Empty;

            foreach (var detail in detailsWrapper)
            {
                text = detail.GetAttribute("innerText").ToUpperInvariant();
                foreach (KeyValuePair <string, int> kvp in countries)
                {
                    if (text.Contains(kvp.Key.ToUpperInvariant()))
                    {
                        countries[kvp.Key] += 1;
                        break; // don't look for multiple matches
                    }
                }
            }

            driver.Quit();
            driver.Dispose();

            var items = from pair in countries
                        orderby pair.Value descending
                        select pair;

            foreach (KeyValuePair <string, int> kvp in items)
            {
                Console.WriteLine("{0}\t{1}", kvp.Key, kvp.Value);
            }
        }
Beispiel #12
0
        public AccountStatement GetAccountStatement(DateTime From, DateTime To)
        {
            if (driver != null)
            {
                try {
                    driver.SwitchTo().Window(driver.CurrentWindowHandle);
                    driver.SwitchTo().Frame("frame_menu");
                    driver.FindElementById("RRAAClink").Click();

                    driver.SwitchTo().Window(driver.CurrentWindowHandle);
                    driver.SwitchTo().Frame("frame_txn");

                    SelectElement elem = new SelectElement(driver.FindElementByName("fldacctno"));
                    elem.SelectByValue(this.Account_Value);

                    //driver.SwitchTo().Window(driver.CurrentWindowHandle);
                    //driver.SwitchTo().Frame("frame_txn");
                    var abcd = driver.FindElementsByClassName("objselect");

                    SelectElement elem2 = new SelectElement(abcd[1]);
                    elem2.SelectByValue("3");

                    driver.FindElementById("fldfromdateid").SendKeys(From.ToString("dd-MM-yyyy"));
                    driver.FindElementById("fldtodateid").SendKeys(To.ToString("dd-MM-yyyy"));

                    driver.FindElementByName("fldsubmit").Click();

                    var      alltables = driver.FindElementsByClassName("graphtable");
                    string   abc       = alltables[0].GetAttribute("innerHTML");
                    Document body      = Supremes.Dcsoup.Parse(abc);

                    AccountStatement statement = new AccountStatement();
                    statement.OpeningBalance = HelpingClass.ToDouble(body.Body.TextNodes[4].Text);
                    statement.ClosingBalance = HelpingClass.ToDouble(body.Body.TextNodes[5].Text);

                    abc  = alltables[1].GetAttribute("innerHTML");
                    body = Supremes.Dcsoup.ParseBodyFragment("<table>" + abc + "</table>");

                    List <AccountActivity> activities = new List <AccountActivity>();
                    AccountActivity        activity   = new AccountActivity();

                    Elements trs = body.Select("tr");
                    Elements tds = null;

                    bool isavilable = false;

                    abc  = driver.FindElementByClassName("standardtable").GetAttribute("innerHTML");
                    body = Supremes.Dcsoup.ParseBodyFragment("<table>" + abc + "</table>");
                    string[] arr         = body.Body.Text.Split(new string[] { "Pages : (" }, StringSplitOptions.None);
                    int      totalpage   = Convert.ToInt32(arr[1].Split(')')[0].Trim());
                    int      currentpage = 1;
                    do
                    {
                        for (int i = 0; i < trs.Count; i++)
                        {
                            if (i != 0)
                            {
                                tds      = trs[i].Select("td");
                                activity = new AccountActivity();

                                activity.TransactionDate        = DateTime.ParseExact(tds[0].OwnText, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                                activity.ValueDate              = DateTime.ParseExact(tds[1].OwnText, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                                activity.TransactionReferenceNo = tds[2].OwnText;
                                activity.Description            = tds[3].OwnText;
                                activity.Debit   = HelpingClass.ToDouble(tds[4].OwnText);
                                activity.Credit  = HelpingClass.ToDouble(tds[5].OwnText);
                                activity.Balance = HelpingClass.ToDouble(tds[6].OwnText);

                                activities.Add(activity);
                            }
                        }

                        if (currentpage < totalpage)
                        {
                            currentpage++;
                            driver.FindElementByCssSelector("a[href=\"javascript:SendPageRequest(" + currentpage.ToString() + ")\"]").Click();

                            alltables = driver.FindElementsByClassName("graphtable");
                            abc       = alltables[1].GetAttribute("innerHTML");
                            body      = Supremes.Dcsoup.ParseBodyFragment("<table>" + abc + "</table>");

                            trs        = body.Select("tr");
                            isavilable = true;
                        }
                        else
                        {
                            isavilable = false;
                        }
                    } while (isavilable);

                    statement.Activities = activities.AsReadOnly();

                    return(statement);
                }

                catch
                {
                    throw new Exception("(ErrorCode:11) Network Or Service is not available Or May be Problem occured While Fetching Account Details Try Again..");
                }
            }

            else
            {
                throw new Exception("(ErrorCode:10) Account Detail object not initialized");
            }
        }