예제 #1
0
        static void Main(string[] args)

        {
           var modem = new Browser();
            var modemURL = "http://192.168.20.1/tr69cfg.html";
                modem.Navigate(modemURL);
            //    Console.Write("get url");
            //    modem.BasicAuthenticationLogin("Broadband Router","admin","admin");
            modem.BasicAuthenticationLogin("192.168.20.1", "admin", "admin");


            modem.Navigate(modemURL);
           //     Console.Write(modem.CurrentHtml);
            var html = modem.CurrentHtml;

            string pattern = @"var sessionKey='([^']+)';";
            Match match = Regex.Match(html, pattern);
            string sessionKey = match.Groups[1].Value;
           // Console.Write(sessionKey);
            sessionKey = getSessionID(html);
           // Console.Write(sessionKey);
           // Console.Read();
            // create response

            // tr69cfg.cgi?tr69cEnable=1&tr69cInformEnable=1&tr69cInformInterval=86402&tr69cAcsURL=http://acs.netcommwireless.com/cpe.php&tr69cAcsUser=cpe&tr69cAcsPwd=cpe&tr69cConnReqUser=cpe&tr69cConnReqPwd=cpe&tr69cConnReqPort=30005&tr69cNoneConnReqAuth=0&tr69cDebugEnable=0&tr69cBoundIfName=Any_WAN&sessionKey=1045881970

            var getstringACS = ACSConfigString(sessionKey);
            modemURL = modemURL + getstringACS;
            modem.Navigate(modemURL);
            vlanConfiguration();
            // need to do 4 posts to configure vlan
        }
예제 #2
0
        static void vlanConfiguration()
        {
            var modem = new Browser();

            var modemURL = "http://192.168.20.1/qinetsetup.html";
            modem.Navigate(modemURL);
            //    Console.Write("get url");
           //    modem.BasicAuthenticationLogin("Broadband Router","admin","admin");
            modem.BasicAuthenticationLogin("192.168.20.1", "admin", "admin");


            modem.Navigate(modemURL);
            //     Console.Write(modem.CurrentHtml);
            var html = modem.CurrentHtml;
            string sessionKey = getSessionID(html);
            // post wlan type
            modemURL = "http://192.168.20.1/qvdslwanmode.cgi?wanType=2&sessionKey=" + sessionKey;
            modem.Navigate(modemURL);
            html = modem.CurrentHtml;
            sessionKey = getSessionID(html);
            modemURL = "http://192.168.20.1/qvdslppp.cgi?ntwkPrtcl=0&enblOnDemand=0&pppTimeOut=0&enblv4=1&useStaticIpAddress=0&pppIpExtension=0&enblFirewall=1&enblNat=1&enblIgmp=1&keepalive=1&keepalivetime=5&alivemaxfail=30&enVlanMux=1&vlanMuxId=69&vlanMuxPr=0&enblPppDebug=0&maxMtu=1492&keepalive=0&enblv6=0&pppAuthErrorRetry=0&pppAuthMethod=0&sessionKey=" + sessionKey;
            modem.Navigate(modemURL);
            html = modem.CurrentHtml;
            sessionKey = getSessionID(html);
            modemURL = "http://192.168.20.1/qsetup.cmd?pppUserName=craignz&pppPassword=craigpassword&portId=0&ptmPriorityNorm=1&ptmPriorityHigh=1&connMode=1&burstsize=3000&enblQos=1&grpPrec=8&grpAlg=WRR&grpWght=1&prec=8&alg=WRR&wght=1&sessionKey=" + sessionKey;
            modem.Navigate(modemURL);
           

        }
		public void TestRussian()
		{
			Browser b = new Browser();
			b.Navigate("http://online3.anextour.ru/");
			var menuItem = b.Select(".menu_top div");
			Assert.That(menuItem.Value == "Турагентствам", "Russian text not found");


			b.Navigate("http://www.funda.nl");

			b.Navigate("http://www.google.com");

		}
		public void TestRussian()
		{
			Browser b = new Browser();
			b.Navigate("http://online3.anextour.ru/");

			var menuItem = b.Select(".mainmenu");
			Assert.That(menuItem.Value.Contains( "Поиск"), "Russian text not found");

		}
예제 #5
0
        public static void LoginEpiserverWebForms(string loginUrl, string username, string password)
        {
            var browser = new Browser();
            browser.Navigate(loginUrl);

            browser.Find("FullRegion_LoginControl_UserName").Value = username;
            browser.Find("FullRegion_LoginControl_Password").Value = password;
            browser.Find("FullRegion_LoginControl_Button1").Click();
            Instance = browser;
        }
예제 #6
0
파일: Doc.cs 프로젝트: friism/Krimikort
 public static string GetArchiveHtmlByPost(string url)
 {
     var browser = new Browser();
     browser.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10";
     browser.Navigate(url);
     browser.ExtraFormValues.Add("__EVENTTARGET", "Archivepagecontrol2:ShowAll");
     var form = browser.Find("Form1");
     var newAction = "/CMS.Politi.Web/Templates/Content/" + form.XElement.GetAttribute("action");
     form.XElement.SetAttributeValue("action", newAction);
     form.SubmitForm();
     return browser.CurrentHtml;
 }
예제 #7
0
        static void Main(string[] args)
        {
            var browser = new Browser();
            try
            {
                // log the browser request/response data to files so we can interrogate them in case of an issue with our scraping
                browser.RequestLogged += OnBrowserRequestLogged;
                browser.MessageLogged += new Action<Browser, string>(OnBrowserMessageLogged);

                // we'll fake the user agent for websites that alter their content for unrecognised browsers
                browser.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10";

                // browse to GitHub
                browser.Navigate("http://www.pogdesign.co.uk/cat/");
                if (LastRequestFailed(browser)) return; // always check the last request in case the page failed to load

                browser.Log("First we need do find a Title with month and year description.");

                var titleLink = browser.Find("a", FindBy.Text, "August 2016 TV Episode Calendar");
                if (!titleLink.Exists)
                {
                    browser.Log("Can't find the link! Perhaps the site is down for maintenance?");
                    return;
                }

                browser.Log("Then we find the yesterday column.");

                // Obter dia
                var dayDiv = browser.Find("div", FindBy.Id, "d_1_8_2016");
                if (!dayDiv.Exists)
                {
                    browser.Log("Can't find the column! Perhaps dont have any series for the month.");
                    return;
                }

                var serieLink = browser.Find("a href", FindBy.PartialText, "-summary");
                if (serieLink.Exists)
                {
                    Console.WriteLine(serieLink.TotalElementsFound);

                    Console.WriteLine(serieLink.FirstOrDefault().Value);
                }

                //// click the login link and click it
                //browser.Log("First we need to log in, so browse to the login page, fill in the login details and submit the form.");
                //var loginLink = browser.Find("a", FindBy.Text, "Login");
                //if (!loginLink.Exists)
                //    browser.Log("Can't find the login link! Perhaps the site is down for maintenance?");
                //else
                //{
                //    loginLink.Click();
                //    if (LastRequestFailed(browser)) return;

                    //    // fill in the form and click the login button - the fields are easy to locate because they have ID attributes
                    //    browser.Find("login_field").Value = "*****@*****.**";
                    //    browser.Find("password").Value = "yourpassword";
                    //    browser.Find(ElementType.Button, "name", "commit").Click();
                    //    if (LastRequestFailed(browser)) return;

                    //    // see if the login succeeded - ContainsText() is very forgiving, so don't worry about whitespace, casing, html tags separating the text, etc.
                    //    if (browser.ContainsText("Incorrect login or password"))
                    //    {
                    //        browser.Log("Login failed!", LogMessageType.Error);
                    //    }
                    //    else
                    //    {
                    //        // After logging in, we should check that the page contains elements that we recognise
                    //        if (!browser.ContainsText("Your Repositories"))
                    //            browser.Log("There wasn't the usual login failure message, but the text we normally expect isn't present on the page");
                    //        else
                    //        {
                    //            browser.Log("Your News Feed:");
                    //            // we can use simple jquery selectors, though advanced selectors are yet to be implemented
                    //            foreach (var item in browser.Select("div.news .title"))
                    //                browser.Log("* " + item.Value);
                    //        }
                    //    }
                    //}
            }
            catch (Exception ex)
            {
                browser.Log(ex.Message, LogMessageType.Error);
                browser.Log(ex.StackTrace, LogMessageType.StackTrace);
            }
            finally
            {
                var path = WriteFile("log-" + DateTime.UtcNow.Ticks + ".html", browser.RenderHtmlLogFile("SimpleBrowser Sample - Request Log"));
                //Process.Start(path);
            }

            Console.ReadKey();
        }
예제 #8
0
 XDocument GetWindow(string url)
 {
     var browser = new Browser();
     browser.Navigate(url);
     return browser.XDocument;
 }
예제 #9
0
        static void Main(string[] args)
        {
            var browser = new Browser();
            try
            {
                // log the browser request/response data to files so we can interrogate them in case of an issue with our scraping
                browser.RequestLogged += OnBrowserRequestLogged;
                browser.MessageLogged += new Action<Browser, string>(OnBrowserMessageLogged);

                // we'll fake the user agent for websites that alter their content for unrecognised browsers
                browser.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10";

                // browse to GitHub
                browser.Navigate("http://github.com/");
                if(LastRequestFailed(browser)) return; // always check the last request in case the page failed to load

                // click the login link and click it
                browser.Log("First we need to log in, so browse to the login page, fill in the login details and submit the form.");
                var loginLink = browser.Find("a", FindBy.Text, "Login");
                if(!loginLink.Exists)
                    browser.Log("Can't find the login link! Perhaps the site is down for maintenance?");
                else
                {
                    loginLink.Click();
                    if(LastRequestFailed(browser)) return;

                    // fill in the form and click the login button - the fields are easy to locate because they have ID attributes
                    browser.Find("login_field").Value = "*****@*****.**";
                    browser.Find("password").Value = "yourpassword";
                    browser.Find(ElementType.Button, "name", "commit").Click();
                    if(LastRequestFailed(browser)) return;

                    // see if the login succeeded - ContainsText() is very forgiving, so don't worry about whitespace, casing, html tags separating the text, etc.
                    if(browser.ContainsText("Incorrect login or password"))
                    {
                        browser.Log("Login failed!", LogMessageType.Error);
                    }
                    else
                    {
                        // After logging in, we should check that the page contains elements that we recognise
                        if(!browser.ContainsText("Your Repositories"))
                            browser.Log("There wasn't the usual login failure message, but the text we normally expect isn't present on the page");
                        else
                        {
                            browser.Log("Your News Feed:");
                            // we can use simple jquery selectors, though advanced selectors are yet to be implemented
                            foreach(var item in browser.Select("div.news .title"))
                                browser.Log("* " + item.Value);
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                browser.Log(ex.Message, LogMessageType.Error);
                browser.Log(ex.StackTrace, LogMessageType.StackTrace);
            }
            finally
            {
                var path = WriteFile("log-" + DateTime.UtcNow.Ticks + ".html", browser.RenderHtmlLogFile("SimpleBrowser Sample - Request Log"));
                Process.Start(path);
            }
        }