예제 #1
0
        private void timerStatsTick(object state)
        {
            lock (loginLock)
            {
                if (!String.IsNullOrEmpty(_user))
                {
                    try
                    {
                        var    result   = loginWC.DownloadString(String.Format(apiUrl, _user));
                        JToken statsObj = JToken.Parse(result);
                        if (statsObj == null)
                        {
                            Debug.Print("Hitbox: Unable to parse stats json");
                            return;
                        }

                        JToken livestreams = statsObj["livestream"];
                        UInt32 counter     = 0;
                        foreach (JObject cat in livestreams)
                        {
                            counter += cat["category_viewers"].Value <UInt32>();
                        }
                        Viewers = counter;
                    }
                    catch (Exception e)
                    {
                        Debug.Print("Hitbox: Stats download error {0} {1}", String.Format(apiUrl, _user), e.InnerException.Message);
                    }
                }
            }
        }
예제 #2
0
        public static bool Login(string username, string password)
        {
            string res = "";

            //c.CookieContainer.SetCookies(new Uri("http://frenchy-ponies.fr"), "phpbb_ma_sid=c7aca50b997055971562307c4be3d745;domain=.frenchy-ponies.fr;path =/");

            try
            {
                byte[] log_res = c.UploadValues(cb_login, "POST", new NameValueCollection()
                {
                    { "username", username },
                    { "password", password },
                    { "redirect", "index.php" },
                    { "login", "Connexion" },
                    { "sid", "2ae96431ff45f50313493d91f6956327" }
                });

                res = c.DownloadString("http://frenchy-ponies.fr/ponybox/pb-include.php");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception for " + username + "/" + password);
                Console.WriteLine(e.Message);
            }

            return(res.Length > 0);
        }
예제 #3
0
        private void fillcurrentpatdata()
        {
            string patmanpage = client.DownloadString(patmanURL);

            textBox_response.Text = patmanpage;

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(patmanpage);

            var TDs = doc.DocumentNode.SelectSingleNode("//tbody").Descendants("tr")
                      .Where(tr => tr.Elements("td").Count() > 1)
                      .Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
                      .ToList();


            currentpatdataList.Clear();
            foreach (List <string> Rows in TDs)
            {
                patterndata pat = new patterndata();
                pat.number    = Rows[3];
                pat.name      = Rows[2].Substring(0, Rows[2].IndexOf("\r\n")); //name
                pat.views     = Rows[8];
                pat.sells     = Rows[9];
                pat.wishlists = Rows[14];
                pat.ratings   = Rows[16];
                pat.score     = Rows[15];

                currentpatdataList.Add(pat);
            }
        }
예제 #4
0
        public void Login(string email, string password)
        {
            string deviceKey   = GetDeviceKey(s_site);
            string api         = "https://login.viaplay." + s_site + "/api";
            string url         = api + "/persistentLogin/v1?deviceKey=" + deviceKey + "&returnurl=http%3A%2F%2Fcontent.viaplay." + s_site + "%2F" + deviceKey;
            bool   loginResult = false;

            try
            {
                dynamic loginPage = Json.JsonDecode(client.DownloadString(url));
                loginResult = loginPage["success"];
            }
            catch
            {
                loginResult = false;
            }
            if (!loginResult)
            {
                string  authUrl   = api + "/login/v1?deviceKey=" + deviceKey + "&returnurl=http%3A%2F%2Fcontent.viaplay." + s_site + "%2F" + deviceKey + "&username="******"&password="******"&persisten=true";
                dynamic loginPage = Json.JsonDecode(client.DownloadString(authUrl));
                if (!loginPage["success"])
                {
                    throw new Exception("Dangit");
                }
            }

            GetSections();
        }
예제 #5
0
        public void AuthenticatedPenUserShouldFailAuthCheck()
        {
            var client = new CookieAwareWebClient();

            client.BaseAddress = "http://localhost:9090/";
            var result = client.DownloadString("/");

            Assert.That.IsTrue(result.IsNotNullOrWhiteSpace());

            client.CookieContainer.Add(new Cookie(".ROCK", "9373243FAEE9455CCFEF205114261C4CAAA451ABEBA8F27713DC015CDE99B3B796A683204D1F7D3FDF949483926A8AC5EDE93AA1655DB1B0AAF7E50062A9F4ACD557C645FD113ECDAEA82BAC152EE09D98EC4696", "/", "localhost"));
            Assert.That.ThrowsExceptionWithMessage <WebException>(() => client.DownloadString($"/api/Badges/InGroupOfType/{1}/{System.Guid.NewGuid()}"), "The remote server returned an error: (401) Unauthorized.");
        }
예제 #6
0
        private void Save_button_Click(object sender, RoutedEventArgs e)
        {
            Save_button.IsEnabled = false;

            var client = new CookieAwareWebClient();

            client.BaseAddress = @"http://www.codeabbey.com/";
            var loginData = new NameValueCollection();

            loginData.Add("username", Login_textBox.Text);
            loginData.Add("password", Passowrd_passwordBox.Password);
            loginData.Add("email", "");
            client.UploadValues("index/login", "POST", loginData);

            string htmlSource = client.DownloadString("index/user_profile");


            var sourceLinksRegex = new Regex("/index/task_solution\\?task=(?<ProblemName>.+?)&.+?lang=(?<Language>.+?)\"");
            var sourceRegex      = new Regex("<code.+?>(?<Code>.+?)</code>", RegexOptions.Singleline);

            var matches = sourceLinksRegex.Matches(htmlSource);

            foreach (Match m in matches)
            {
                var url         = "http://www.codeabbey.com" + m.ToString().Replace("\"", "");
                var relativeUrl = m.ToString().Replace("\"", "");

                var lang        = HttpUtility.UrlDecode(m.Groups["Language"].Value);
                var problemName = HttpUtility.UrlDecode(m.Groups["ProblemName"].Value);

                var sourcePageHtml = client.DownloadString(relativeUrl);


                var source = HttpUtility.HtmlDecode(sourceRegex.Match(sourcePageHtml).Groups["Code"].Value);

                var validLangFolder = CleanFileName(lang);
                var validFileNameWithProblemCode = CleanFileName(problemName) + ".txt";

                if (!Directory.Exists(validLangFolder))
                {
                    Directory.CreateDirectory(validLangFolder);
                }

                File.WriteAllText(validLangFolder + @"\" + validFileNameWithProblemCode, source);
            }

            Save_button.IsEnabled = true;

            MessageBox.Show("Done!");
        }
예제 #7
0
        public bool LoadInputFromURL(string url)
        {
            try
            {
                if (String.IsNullOrEmpty(HTTPPostVariables))
                {
                    //get
                    InputData = webClient.DownloadString(url);
                }
                else
                {
                    //post
                    InputData = webClient.UploadString(url, HTTPPostVariables);
                }

                // cache result if we received a response

                /*if (InputData.Length > 512)
                 * {
                 *  var cacheFile = InputPath + "\\cache_" + ProviderName + ".dat";
                 *  System.IO.File.WriteAllText(cacheFile, InputData);
                 * }*/

                return(true);
            }
            catch (Exception)
            {
                Log(": Failed to fetch input from url :" + url);
                return(false);
            }
        }
        private CodeExecutionResponse GetCodeExecutionResult(string executionResultLinkId)
        {
            var requestUrl = string.Format(IdeOneBaseUrl + CodeExecutionResultPostfixTemplate, executionResultLinkId);

            while (true)
            {
                string httpResponse;

                using (var client = new CookieAwareWebClient())
                {
                    httpResponse = client.DownloadString(requestUrl);
                }

                var responseObject = (dynamic)JsonConvert.DeserializeObject(httpResponse);

                if ((CodeExecutionStatus)responseObject.status != CodeExecutionStatus.Running &&
                    (CodeExecutionStatus)responseObject.status != CodeExecutionStatus.Compilation &&
                    (CodeExecutionStatus)responseObject.status != CodeExecutionStatus.WaitingForCompilation)
                {
                    return(ConvertHttpResponseToExecutionResponse(responseObject));
                }

                Task.Delay(CodeExecutionResultCheckTimeout);
            }
        }
예제 #9
0
        public static dynamic LoadUser(string username, string password)
        {
            CookieAwareWebClient c = new CookieAwareWebClient();
            string res             = "";

            //c.CookieContainer.SetCookies(new Uri("http://frenchy-ponies.fr"), "phpbb_ma_sid=c7aca50b997055971562307c4be3d745;domain=.frenchy-ponies.fr;path =/");

            try
            {
                byte[] log_res = c.UploadValues(cb_login, "POST", new NameValueCollection()
                {
                    { "username", username },
                    { "password", password },
                    { "redirect", "index.php" },
                    { "login", "Connexion" },
                    //{ "sid", "a6cce2c9a9448a93eab7002f5f459829" }
                });

                string s = Encoding.Default.GetString(log_res);
                //File.WriteAllText(@"D:\Test.html",s);

                res = c.DownloadString("http://frenchy-ponies.fr/ponybox/pb-include.php");
                Console.WriteLine(res);
            }
            catch (Exception e) {
                Console.WriteLine("Exception for " + username + "/" + password);
                Console.WriteLine(e.Message);
            }

            return(res);
        }
예제 #10
0
        public static Tuple <string, string> LoginForum(string username, string password)
        {
            CookieAwareWebClient c = new CookieAwareWebClient();

            try
            {
                byte[] log_res = c.UploadValues(cb_login, "POST", new NameValueCollection()
                {
                    { "username", username },
                    { "password", password },
                    { "redirect", "index.php" },
                    { "login", "Connexion" },
                    //{ "sid", "a6cce2c9a9448a93eab7002f5f459829" }
                });

                string s = Encoding.Default.GetString(log_res);

                string res = c.DownloadString(cb_include);
                Console.WriteLine(res);
                return(ParseToken(res));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception for " + username + "/" + password);
                Console.WriteLine(e.Message);
                return(null);
            }
        }
        public string Captcha(string value)
        {
            CookieContainer _cookies   = new CookieContainer();
            var             htmlResult = string.Empty;

            using (var wc = new CookieAwareWebClient(_cookies))
            {
                wc.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)";
                wc.Headers[HttpRequestHeader.KeepAlive] = "300";
                htmlResult = wc.DownloadString(urlBaseReceitaFederal + paginaPrincipal);
            }

            if (htmlResult.Length > 0)
            {
                var wc2 = new CookieAwareWebClient(_cookies);
                wc2.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)";
                wc2.Headers[HttpRequestHeader.KeepAlive] = "300";
                byte[] data = wc2.DownloadData(urlBaseReceitaFederal + paginaCaptcha);

                CacheHelper.Add("CookieReceitaFederal_" + value, _cookies);

                return("data:image/jpeg;base64," + System.Convert.ToBase64String(data, 0, data.Length));
            }

            return(string.Empty);
        }
예제 #12
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var client = new CookieAwareWebClient())
     {
         if (tbx_UserName.Text == "" || tbx_Password.Text == "")
         {
             MessageBox.Show("Bạn chưa nhập đủ thông tin", "Lỗi");
         }
         else
         {
             if (!File.Exists("data.dat") || mssv != tbx_UserName.Text || password != tbx_Password.Text)
             {
                 File.Delete("data.dat");
                 Ghi_DuLieu();
             }
             var values = new NameValueCollection {
                 { "txtTaiKhoan", tbx_UserName.Text }, { "txtMatKhau", tbx_Password.Text }
             };
             client.Encoding = Encoding.UTF8;
             client.UploadValues(new Uri("http://online.dlu.edu.vn/Login"), "POST", values);
             var html = client.DownloadString(@"http://online.dlu.edu.vn/Home/DrawingStudentSchedule?StudentId=1610207&YearId=2017-2018&TermId=HK02&WeekId=3");
             if (html.Contains("<title>Đăng nhập</title>"))
             {
                 MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 webBrowser1.DocumentText = html;
             }
         }
     }
 }
예제 #13
0
 private static string GetMetadata(Uri metadataUri)
 {
     using (var client = new CookieAwareWebClient())
     {
         return(client.DownloadString(metadataUri));
     }
 }
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            string userName = this.UserNameBox.Text;
            string password = this.PasswordBox.Password;

            using (var webClient = new CookieAwareWebClient())
            {
                try
                {
                    NameValueCollection collection = new NameValueCollection
                    {
                        {"UserName", userName},
                        {"Password", password}
                    };

                    webClient.UploadValues("https://judge.softuni.bg/Account/Login", "POST", collection);

                    
                    string result = webClient.DownloadString("https://judge.softuni.bg/Contests/Compete/Results/Simple/104");

                }
                catch (WebException webException)
                {
                    MessageBox.Show(webException.Status.ToString());
                }
            }

           var jugdeInformationGetter = new JugdeInformationCollector();
           this.Close();
           jugdeInformationGetter.ShowDialog();

        }
예제 #15
0
        public static void GenerateTokens()
        {
            c = new CookieAwareWebClient();

            HtmlNode.ElementsFlags.Remove("form");
            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(c.DownloadString(url_register));

            HtmlNode NodeRegister = doc.GetElementbyId("agreement");

            List <HtmlNode> inputs = NodeRegister.Descendants("input").ToList();

            string timestamp = "";
            string token     = "";

            foreach (HtmlNode input in inputs)
            {
                if (input.GetAttributeValue("name", "") == "form_token")
                {
                    token = input.GetAttributeValue("value", "");
                }
                else if (input.GetAttributeValue("name", "") == "creation_time")
                {
                    timestamp = input.GetAttributeValue("value", "");
                }
            }

            Console.WriteLine("Timestamp : " + timestamp + " | Token : " + token);

            LoadRegisterData(timestamp, token);
        }
예제 #16
0
        public static string GetCaptcha()
        {
            CookieContainer _cookies   = new CookieContainer();
            var             htmlResult = string.Empty;

            using (var wc = new CookieAwareWebClient(_cookies))
            {
                wc.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)";
                wc.Headers[HttpRequestHeader.KeepAlive] = "300";
                htmlResult = wc.DownloadString(urlBaseReceitaFederal + paginaPrincipal);
            }

            if (htmlResult.Length > 0)
            {
                var wc2 = new CookieAwareWebClient(_cookies);
                wc2.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)";
                wc2.Headers[HttpRequestHeader.KeepAlive] = "300";
                byte[] data = wc2.DownloadData(urlBaseReceitaFederal + paginaCaptcha);

                HttpContext.Current.Session["cookies"] = _cookies;

                return("data:image/jpeg;base64," + Convert.ToBase64String(data, 0, data.Length));
            }

            return(string.Empty);
        }
예제 #17
0
        private void timerPollChatTick(object state)
        {
            if (String.IsNullOrEmpty(ChatURL) ||
                !ChatURL.StartsWith("http"))
            {
                return;
            }
            lock (lockChatDownload)
            {
                String result = string.Empty;
                chatWC.Headers = Headers;
                try
                {
                    switch (Method)
                    {
                    case RequestMethod.GET:
                        result = chatWC.DownloadString(ChatURL);
                        break;

                    case RequestMethod.POST:
                        result = chatWC.UploadString(ChatURL, ChatParams);
                        break;

                    case RequestMethod.LOWPOST:
                        result = chatWC.postFormDataLowLevel(ChatURL, ChatParams);
                        break;
                    }
                    OnChatReceive(result);
                }
                catch (Exception e)
                {
                    Debug.Print(String.Format("WebPollChat download error: {0} {1}", ChatURL, e.Message));
                }
            }
        }
        private dynamic DownloadItem(SiteEnum site, string filename, CookieAwareWebClient cookieAwareWebClient)
        {
            var id        = FilenameToId(filename);
            var url       = this.resolver.Resolve(site) + string.Format(UrlFormat, id);
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            CQ dom = this.retry.RetryWeb(
                () => cookieAwareWebClient.DownloadString(new Uri(url)),
                x => this.Logger.Error($"Thread:{Thread.CurrentThread.ManagedThreadId:00} Id:{id} Elapsed:{stopwatch.ShortElapsed()}", x));

            stopwatch.Stop();
            var message =
                $"Record:{(this.total++).ToString("00000")} Thread:{Thread.CurrentThread.ManagedThreadId:00} Id:{id} Elapsed:{stopwatch.ShortElapsed()}";

            if (stopwatch.Elapsed.Seconds <= 5)
            {
                this.Logger.Info(message);
            }
            else
            {
                this.Logger.Warn(message);
            }
            return(new { Id = id, Dom = dom });
        }
예제 #19
0
        private IEnumerable <CQ> GetResultItems(string baseUrl)
        {
            using (var cookieAwareWebClient = new CookieAwareWebClient())
            {
                for (int i = 1; i < 1000; i++) // NOTE: this page count will be a problem if the vacancy count goes above 100,000
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    CQ dom = cookieAwareWebClient.DownloadString(baseUrl + string.Format(UrlFormat, i, this.settings.PageSize));
                    stopwatch.Stop();
                    var message = $"Page:{i} Elapsed: {stopwatch.ShortElapsed()}";
                    if (stopwatch.Elapsed.TotalSeconds <= 5)
                    {
                        this.Logger.Info(message);
                    }
                    else
                    {
                        this.Logger.Warn(message);
                    }

                    Thread.Sleep(this.settings.WaitBetweenRequestsMs);
                    var domObjects = dom[".search-results__item"];
                    if (domObjects.Length == 0)
                    {
                        break;
                    }

                    foreach (var item in domObjects)
                    {
                        yield return(new CQ(item));
                    }
                }
            }
        }
예제 #20
0
 private String HttpGet(String url)
 {
     lock (loginLock)
     {
         loginWC.ContentType = ContentType.UrlEncodedUTF8;
         //loginWC.Headers["X-Requested-With"] = "XMLHttpRequest";
         try
         {
             var result = loginWC.DownloadString(url);
             if (!String.IsNullOrEmpty(result))
             {
                 return(result);
             }
             else
             {
                 Debug.Print("Cybergame: httpget - empty string fetched from {0}", url);
             }
         }
         catch (Exception e)
         {
             Debug.Print("Cybergame error fetching {0}: {1}", url, e.Message);
         }
     }
     return(String.Empty);
 }
예제 #21
0
        public List <Session> GetSessions(DateTime logintime)
        {
            var sessions = new List <Session>();

            if (!IsLoggedIn)
            {
                Login();
            }
            lock (_webClientLock)
            {
                var input   = _webClient.DownloadString("http://buddyauth.com/User/Sessions");
                var regex   = new Regex("<tr>[^<]+<td>.+name=\"selectedSessions\\[([0-9]+)\\].Id\".+value=\"(.+)\"[^<]+<input[^<]+<input[^<]+<[^<]+<td>Demonbuddy</td>[^<]+<td>([^<]+)<");
                var session = new Session();
                foreach (Match match in regex.Matches(input))
                {
                    // Get login time for each session
                    // Sample: 7/30/2012 7:51:45 PM
                    var number = match.Groups[1].ToString();
                    var id     = match.Groups[2].ToString();
                    var time   = match.Groups[3].ToString().Trim();
                    var result = DateTime.Parse(time, new CultureInfo("en-US", false));

                    Debug.WriteLine("Found Session: id:{0} time:{1}", id, result);
                    session.id     = int.Parse(id);
                    session.time   = result;
                    session.number = int.Parse(number);
                    sessions.Add(session);
                }
            }

            return(sessions);
        }
예제 #22
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (username.Text != "" && password.Password != "")
            {
                try
                {
                    using (var client = new CookieAwareWebClient())
                    {
                        var values = new NameValueCollection
                        {
                            { "login", username.Text },
                            { "pass", password.Password },
                        };

                        client.UploadValues("http://www.europeconomic.net/", values);

                        // If the previous call succeeded we now have a valid authentication cookie
                        // so we could download the protected page
                        string result = client.DownloadString("http://www.europeconomic.net/index.php?p=ticket");

                        richTextBox1.SelectAll(); richTextBox1.Selection.Text = result.ToString();
                    }
                }
                catch
                {
                    MessageBox.Show("Erreur d'accès au réseau");
                }
            }
            else
            {
                MessageBox.Show("Attention identifiants de connexion vides !");
            }
        }
예제 #23
0
        private void CheckForUpdatesClick(object sender, RoutedEventArgs e)
        {
            // Get the current internal version
            var    assemblyVersion = Assembly.GetEntryAssembly().GetName().Version;
            string version         = $"{assemblyVersion.Major}.{assemblyVersion.Minor}" + (assemblyVersion.MajorRevision != 0 ? $".{assemblyVersion.MajorRevision}" : string.Empty);

            // Get the latest tag from GitHub
            using (var client = new CookieAwareWebClient())
            {
                client.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0";

                // TODO: Figure out a better way than having this hardcoded...
                string url = "https://api.github.com/repos/SabreTools/DICUI/releases/latest";
                string latestReleaseJsonString = client.DownloadString(url);
                var    latestReleaseJson       = JObject.Parse(latestReleaseJsonString);
                string latestTag  = latestReleaseJson["tag_name"].ToString();
                string releaseUrl = latestReleaseJson["html_url"].ToString();

                bool different = version != latestTag;

                string message = $"Local version: {version}"
                                 + $"{Environment.NewLine}Remote version: {latestTag}"
                                 + (different
                        ? $"{Environment.NewLine}The update URL has been added copied to your clipboard"
                        : $"{Environment.NewLine}You have the newest version!");

                // If we have a new version, put it in the clipboard
                if (different)
                {
                    Clipboard.SetText(releaseUrl);
                }

                MessageBox.Show(message, "Version Update Check", MessageBoxButton.OK, different ? MessageBoxImage.Exclamation : MessageBoxImage.Information);
            }
        }
예제 #24
0
        public void DownloadChat()
        {
            lock (chatLock)
            {
                var result = "";
                try
                {
                    result = loginWC.DownloadString(String.Format(getChatUrl, UserID, TimeUtils.UnixTimestamp()));
                }
                catch {
                    Debug.Print("EmpireTV: chat download failed");
                    return;
                }
                if (String.IsNullOrEmpty(result))
                {
                    return;
                }

                var messages = ParseJson <List <Message> > .ReadObject(result);

                if (messages == null)
                {
                    return;
                }

                if (!LoadHistory && Messages == null)
                {
                    lastMessages = messages;
                }

                Messages = messages.Except(lastMessages, new LambdaComparer <Message>((x, y) => x.id == y.id)).ToList();

                if (Messages == null)
                {
                    return;
                }

                if (OnNewMessage != null && Messages.Count > 0)
                {
                    lastMessages = messages;
                    foreach (var m in Messages)
                    {
                        OnNewMessage(this, new MessageArgs(m));
                    }
                }
            }
        }
        private dynamic DownloadItem(SiteEnum site, string filename, CookieAwareWebClient cookieAwareWebClient)
        {
            var id  = filename.Substring(filename.LastIndexOf("\\") + 1).Split('.').First();
            var url = this.resolver.Resolve(site) + string.Format(UrlFormat, id);
            CQ  dom = cookieAwareWebClient.DownloadString(url);

            return(new { Id = id, Dom = dom });
        }
예제 #26
0
        public String GetStreamID()
        {
            if (!LoggedIn)
            {
                return(String.Empty);
            }

            var content = loginWC.DownloadString(urlUserStream);

            String streamId = GetSubString(content, reStreamId, 1);

            if (String.IsNullOrEmpty(streamId))
            {
                return(String.Empty);
            }

            return(streamId);
        }
        public string DownloadPage(string formattedUrl, params object[] args)
        {
            string url = string.Format(formattedUrl, args);

            using (CookieAwareWebClient client = this.GetLoggedInWebClient())
            {
                string response = client.DownloadString(url);

                return(response);
            }
        }
예제 #28
0
        public void AuthenticatedUserShouldReturnData()
        {
            var client = new CookieAwareWebClient();

            client.BaseAddress = "http://localhost:9090/";
            client.Headers[HttpRequestHeader.ContentType] = "application/json";
            var result = client.UploadString("api/Auth/Login", "{'Username': '******','Password': '******'}");

            Assert.That.IsTrue(result.IsNullOrWhiteSpace());

            result = client.DownloadString($"/api/Badges/InGroupOfType/{1}/{System.Guid.NewGuid()}");
            Assert.That.IsTrue(result.IsNotNullOrWhiteSpace());
        }
예제 #29
0
 public Concurso Consultar(int numero)
 {
     if (!concursos.ContainsKey(numero))
     {
         var document = parser.Parse(client.DownloadString("http://loterias.caixa.gov.br/wps/portal/loterias/landing/megasena/"));
         var url      = document.QuerySelector("base").GetAttribute("href");
         var action   = document.Body.QuerySelector("form[name=\"buscaForm\"]").GetAttribute("action");
         System.Collections.Specialized.NameValueCollection formData = new System.Collections.Specialized.NameValueCollection();
         formData["concurso"] = numero.ToString();
         byte[] responseBytes = client.UploadValues($"{url}{action}", "POST", formData);
         var    concurso      = new Concurso(parser.Parse(Encoding.UTF8.GetString(responseBytes)));
         concursos.Add(numero, concurso);
     }
     return(concursos[numero]);
 }
예제 #30
0
        private IEnumerable <dynamic> DownloadPages(IEnumerable <string> filenames, SiteEnum site)
        {
            using (var cookieAwareWebClient = new CookieAwareWebClient())
            {
                foreach (var filename in filenames)
                {
                    var id  = filename.Substring(filename.LastIndexOf("\\") + 1).Split('.').First();
                    var url = this.resolver.Resolve(site) + string.Format(UrlFormat, id);
                    CQ  dom = cookieAwareWebClient.DownloadString(url);
                    yield return(new { Id = id, Dom = dom });

                    Thread.Sleep(WaitBetweenRequestsMs);
                }
            }
        }
예제 #31
0
        private bool init_goodgame()
        {
            string               uri                  = "http://goodgame.ru/chat/" + channelName;
            CookieContainer      cookieContainer      = new CookieContainer();
            CookieAwareWebClient cookieAwareWebClient = new CookieAwareWebClient(cookieContainer);

            cookieAwareWebClient.Headers.Add("user-agent", "BlitzChat");
            cookieAwareWebClient.Encoding = Encoding.UTF8;
            try
            {
                string input = cookieAwareWebClient.DownloadString(new Uri(uri, UriKind.RelativeOrAbsolute)).Replace('\n', ' ').Replace('\r', ' ');
                Regex  regex = new Regex("BPC=(.*?)\"");
                Match  match = regex.Match(input);
                cookieContainer.Add(new Cookie("BPC", match.Groups[1].Value, "/", "goodgame.ru"));
                uri  += "?attempt=1";
                input = cookieAwareWebClient.DownloadString(new Uri(uri, UriKind.RelativeOrAbsolute)).Replace('\n', ' ').Replace('\r', ' ');
                regex = new Regex("token.*?\\'(.*?)\\'.*?channelId\\:(.*?)\\,.*?\\'(.*?)\\'", RegexOptions.Multiline);
                match = regex.Match(input);
                if (!match.Success)
                {
                    channelId = 0;
                    token     = "";
                    return(false);
                }
                token     = match.Groups[1].Value;
                channelId = uint.Parse(match.Groups[2].Value);
                //this.channelName = match.Groups[3].Value;
            }
            catch (Exception)
            {
                channelId = 0;
                return(false);
            }
            connectSocket();
            return(true);
        }
예제 #32
0
        static void Main()
        {
            var client = new CookieAwareWebClient();
            client.BaseAddress = @"http://bgcoder.com";
            var loginData = new NameValueCollection();
            loginData.Add("UserName", username);
            loginData.Add("Password", password);
            client.UploadValues("/Account/LogOn", "POST", loginData);
 
            string htmlSource = client.DownloadString("Contest/ContestResults/" + numberOfContest);
 
            int[] grades = ExtractGrades(htmlSource);
 
            WriteToConsole(htmlSource, grades);
        }      
예제 #33
0
    public static List<string> FileSearch(Uri uriObj1)
    {
        List<string> returnString = new List<string>();
         HtmlTag tag;
         CookieAwareWebClient client = new CookieAwareWebClient();
         client.CookieContainer = Web.CC;
         string html = client.DownloadString(uriObj1);
         HtmlParser parse = new HtmlParser(html);
         string returnedValue = "";
         string value1;
         while (parse.ParseNext("a", out tag))
         {
             if (tag.Attributes.TryGetValue("href", out value1))
             {
                 returnedValue = value1;
                 if (searchKeyword(returnedValue, "http://10.1.1.242/moodle/") && searchKeyword(returnedValue, ".pdf"))
                 {
                     returnString.Add(returnedValue);
                 }
                 if (searchKeyword(returnedValue, "http://10.1.1.242/moodle/") && searchKeyword(returnedValue, ".ppt"))
                 {
                     returnString.Add(returnedValue);
                 }
                 if (searchKeyword(returnedValue, "http://10.1.1.242/moodle/") && searchKeyword(returnedValue, ".doc"))
                 {
                     returnString.Add(returnedValue);
                 }
                 if (searchKeyword(returnedValue, "http://10.1.1.242/moodle/") && searchKeyword(returnedValue, ".docx"))
                 {
                     returnString.Add(returnedValue);
                 }
                 if (searchKeyword(returnedValue, "http://10.1.1.242/moodle/") && searchKeyword(returnedValue, ".dwg"))
                 {
                     returnString.Add(returnedValue);
                 }
             }

             //Console.WriteLine("Exiting filesearch...........");
         }
         return returnString;
    }
예제 #34
0
 private void parseStreamerName() {
     string uri = "http://gamerstv.ru/video/i" + chatId+".html";
     CookieContainer cookieContainer = new CookieContainer();
     CookieAwareWebClient cookieAwareWebClient = new CookieAwareWebClient(cookieContainer);
     cookieAwareWebClient.Headers.Add("user-agent", "BlitzChat");
     cookieAwareWebClient.Encoding = Encoding.GetEncoding("Windows-1251");
     try
     {
         string input = cookieAwareWebClient.DownloadString(new Uri(uri, UriKind.RelativeOrAbsolute)).Replace('\n', ' ').Replace('\r', ' ');
         Regex regex = new Regex("<span class=\"name\">(.*?)</span>", RegexOptions.Multiline);
         Match match = regex.Match(input);
         if (!match.Success)
         {
             streamerName = "";
         }
         streamerName = match.Groups[1].Value;
     }
     catch (Exception e)
     {
         Debug.Print("Exception on parsing userId from gamersTV: "+e.Message);
     }
 }
        public static void Connect(string email, string password, bool useSessionId = false)
        {
            WebClinet = new CookieAwareWebClient();
            if (useSessionId)
            {
                WebClinet.Cookies.Add(new System.Net.Cookie("PHPSESSID", password, "/", "www.pathofexile.com"));
            }
            else
            {
                string loginHtml = WebClinet.DownloadString(LOGINURL);
                HtmlDocument h = new HtmlDocument();
                h.LoadHtml(loginHtml);
                string hash = h.DocumentNode.SelectNodes("//input[@name='hash']").First().Attributes["value"].Value;

                WebClinet.BaseAddress = LOGINURL;
                var loginData = new NameValueCollection();
                loginData.Add("login_email", email);
                loginData.Add("login_password", password);
                loginData.Add("login", "Login");
                loginData.Add("remember_me", "0");
                loginData.Add("hash", hash);
                WebClinet.UploadValues("/login", "POST", loginData);
            }
        }
예제 #36
0
    // End Of Function Home PAge Search
    public static List<string> FolderSearch(Uri uriObj1)
    {
        List<string> returnString = new List<string>();
        HtmlTag tag;
        CookieAwareWebClient client = new CookieAwareWebClient();
        client.CookieContainer = Web.CC;
        string html = client.DownloadString(uriObj1);
        HtmlParser parse = new HtmlParser(html);
        string returnedValue = "";
        string value1;
        while (parse.ParseNext("a", out tag))
        {
            if (tag.Attributes.TryGetValue("href", out value1))
            {
                returnedValue = value1;
                if((searchKeyword(returnedValue, "http://10.1.1.242/moodle/mod/folder/")&&(returnedValue!="http://10.1.1.242/moodle/course/index.php")))
                {
                    returnString.Add(returnedValue);
                }
            }

        }
        return returnString;
    }
        public override void Login(string s)
        {
            _client = new CookieAwareWebClient(_webConnectionStuff.CookieJar);
            string downloadString = _client.DownloadString("https://accounts.coursera.org/signin");
            //Coursera requires a course name to get the initial cookie
            //_webConnectionStuff.GetCookieToken("https://accounts.coursera.org/signin", "csrf_token"); //LectureUrlFromName(s)

            // call the authenticator url
            StringBuilder postData = new StringBuilder();
            postData.Append("?email=" + HttpUtility.UrlEncode(Username1) + "&");
            postData.Append("password="******"&");
            postData.Append("webrequest=true");
            _client = new CookieAwareWebClient(_webConnectionStuff.CookieJar);
            _client.Referer = LOGIN_URL;
            _client.Method = "POST";
            string response1 = _client.DownloadString(LOGIN_URL + postData.ToString());

            _webConnectionStuff.MakeHttpWebCall("https://accounts.coursera.org/signin"); //.GetCookieToken("https://accounts.coursera.org/signin", "csrf_token"); //LectureUrlFromName(s)

            //_webConnectionStuff.CookieJar.GetCookies(new Uri("https://accounts.coursera.org/signin"));

            //Dictionary<string, string> newHeader = new Dictionary<string, string>
            //{
            //    {"X-CSRFToken", "test"} // cookieToken.Value}
            //};

            //Cookie crsfCookie = new Cookie("csrftoken", "test" /*cookieToken.Value*/, "/", ".coursera.org");

            //_webConnectionStuff.SetLoginCookie(LOGIN_URL, postData.ToString(), newHeader, crsfCookie, new Uri("https://class.coursera.org"));

            //TODO: Check this method for lecturename
            //_webConnectionStuff.Login(LectureUrlFromName(s), LOGIN_URL, postData.ToString());

            //CookieContainer cookieJar = new CookieContainer();
            _client = new CookieAwareWebClient(_webConnectionStuff.CookieJar);
            _client.Referer = LOGIN_URL;
            _client.Method = "POST";

            // the website sets some cookie that is needed for login, and as well the 'authenticity_token' is always different
            string response = _client.DownloadString(LOGIN_URL + postData.ToString());
        }
예제 #38
0
        public override bool Login()
        {
            CookieContainer cookieJar = new CookieContainer();
            _client = new CookieAwareWebClient(cookieJar);
            _client.Referer = LOGIN_URL;

            // the website sets some cookie that is needed for login, and as well the 'authenticity_token' is always different
            string response = _client.DownloadString(LOGIN_URL);

            // parse the 'authenticity_token' and cookie is auto handled by the cookieContainer
            string token1 = Regex.Match(response, "authenticity_token.+?value=\"(.+?)\"").Groups[1].Value;
            StringBuilder postData1 = new StringBuilder();
            postData1.Append("/utf8=%E2%9C%93&"); //UTF-8 checkmark
            postData1.Append("authenticity_token=" + HttpUtility.UrlEncode(token1) + "&");
            postData1.Append("uv_login=&return=&");
            postData1.Append("email=" + HttpUtility.UrlEncode(Username) + "&");
            postData1.Append("password="******"&");
            postData1.Append("remember_me=1&button=");

            //WebClient.UploadValues is equivalent of Http url-encode type post
            _client.Method = "POST";
            response = _client.UploadString("https://www.futurelearn.com/sign-in", postData1.ToString());

            //Now that we've logged in, set the Method back to "GET"
            _client.Method = "GET";

            //Now get the goods (cookies should be set!)

            /*
             * EXAMPLE FUTURELEARN RESPONSE
             * cache-control:no-cache
             * cf-ray:1447a9f1151c053a-YYZ
             * content-type:text/html; charset=utf-8
             * date:Fri, 04 Jul 2014 01:49:01 GMT
             * location:https://www.futurelearn.com/courses/cancer-and-the-genomic-revolution/todo
             * server:cloudflare-nginx
             * set-cookie:_future_learn_session=SzZWUS9VRmtSUU5FYjQwZ0RqWmF2cEk5STd4eGdtS0I3bjdYY1NyOEhYdUxFMUFZdmZZOEhvcEM4akJzK3RuWnZNak9RNHhkTURZcW1aeGNPTUNrV3BaTUZkQVlZc3Vja2FqamxDUmNJa2Y2bUFtaWF2R3pleUI4T3lOcjJXR1ZUVmk1OXNlZjl4ZFRDVVBTKzlQVW9kVlRLS3lDb1l6dloyV1RzUGRHM2tXZFlxSnhHdXc0TzB1QlNlRy84cXJkdldrMDZONUw0ejhvMFFHQlhVM3NvVzFBZS9tUk5LSXFyczVpMVpMbmhZZFBYR013NjNpdjRhUnNpT0hmZEhYSjM5dnpsRE9EQ05mTmZ6dG1VN0wzSHc9PS0taWxMWTNjejAxOGw0dnNNUXUrSzNQZz09--02c3904cebd1a27fa010c4569a04cb28c2ed15dd; path=/; secure; HttpOnly
             * set-cookie:session_last_active_at=BAhsKwcVCLZT--143cab77e1d41cea4983f60126a354c0b3a658a0; path=/; expires=Sun, 06 Jul 2014 01:49:09 -0000; secure; HttpOnly
             * status:302 Found
             * status:302 Found
             * version:HTTP/1.1
             * x-bypass:1
             * x-content-type-options:nosniff
             * x-frame-options:SAMEORIGIN
             * x-request-id:e0d8a468-86e9-4760-8103-b25fe7771815
             * x-runtime:0.115527
             * x-ua-compatible:IE=edge
             * x-xss-protection:1; mode=block
             */

            return true;
        }
예제 #39
0
    //public static string[] Courses = { "BITS F110" };
    public static string HomePageSearch(Uri uriObj1, string pattern)
    {
        HtmlTag tag;

        CookieAwareWebClient client = new CookieAwareWebClient();

        client.CookieContainer = Web.CC;

        string html = client.DownloadString(uriObj1);

        HtmlParser parse = new HtmlParser(html);

        string returnedValue = "" ;

        while (parse.ParseNext("a", out tag))
        {
            // See if this anchor links to us
            string value1, storeurl1, value2, storeurl2;
            storeurl1 = ""; storeurl2 = "";
            value1 = "";
            value2 = "";
            if (tag.Attributes.TryGetValue("href", out value1))
            {
                // value contains URL referenced by this link
                //Console.WriteLine(value);
                storeurl1 = value1;
                value1 = "";
            }
            if (tag.Attributes.TryGetValue("title", out value2))
            {
                // value contains URL referenced by this link
                //Console.WriteLine(value);
                storeurl2 = value2;
                returnedValue = usefulUrl(storeurl2);
                Console.WriteLine(returnedValue);
            }

                if ((returnedValue == pattern)&&(storeurl1!="http://10.1.1.242/moodle/course/index.php"))
                {
                    return storeurl1;
                }

        }
        return null;  // debug problem .
    }
예제 #40
0
 public static string GetFolderName(Uri uriObj)
 {
     CookieAwareWebClient client = new CookieAwareWebClient();
     client.CookieContainer = CC;
     client.Proxy = null;
     string html = client.DownloadString(uriObj);
     Regex regex = new Regex("<h2 class=\"main\">(.*)</h2>");
     var v = regex.Match(html);
     return v.Groups[1].ToString();
 }
예제 #41
0
        public static Stats GetStats()
        {
            string data = "Username=admin&Password="******"http://192.168.1.254/html/settings/a_internet.html");

            string output = wc.UploadString("http://192.168.1.254/index/login.cgi?RequestFile=/html/home/home.html&ActionID=95", data);

            string outputPage = wc.DownloadString("http://192.168.1.254/html/settings/a_internet.html");

            Stats stats = Extract(outputPage);

            return stats;
        }
예제 #42
0
        public static string GetCaptcha()
        {
            CookieContainer _cookies = new CookieContainer();
            var htmlResult = string.Empty;

            using (var wc = new CookieAwareWebClient(_cookies))
            {
                wc.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)";
                wc.Headers[HttpRequestHeader.KeepAlive] = "300";
                htmlResult = wc.DownloadString(urlBaseReceitaFederal + paginaPrincipal);
            }

            if (htmlResult.Length > 0)
            {
                var wc2 = new CookieAwareWebClient(_cookies);
                wc2.Headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; Synapse)";
                wc2.Headers[HttpRequestHeader.KeepAlive] = "300";
                byte[] data = wc2.DownloadData(urlBaseReceitaFederal + paginaCaptcha);

                HttpContext.Current.Session["cookies"] = _cookies;

                return "data:image/jpeg;base64," + Convert.ToBase64String(data, 0, data.Length);
            }

            return string.Empty;
        }
예제 #43
0
        public bool Login()
        {
            if (stopped)
                return false;

            lock (chatLock)
            {
                try
                {

                    if (String.IsNullOrEmpty(_user) || String.IsNullOrEmpty(_password))
                        return false;

                    chatWC = new CookieAwareWebClient();

                    chatWC.Headers["Cache-Control"] = "no-cache";
                    chatWC.DownloadString(loginUrl);
                    chatWC.setCookie("kt_is_visited", "1", ".cybergame.tv");
                    chatWC.setCookie("kt_tcookie", "1", ".cybergame.tv");

                    string loginParams = String.Format("action=login&username={0}&pass={1}&remember_me=1", _user, _password);

                    var res = chatWC.postFormDataLowLevel(loginUrl, loginParams);
                    
                    if (string.IsNullOrEmpty(res))
                    {
                        Debug.Print("Cybergame: couldn't get login URL");
                        return false;
                    }

                    res = chatWC.DownloadString(loginUrl);
                    if (!res.Contains("logout.php"))
                    {
                        Debug.Print("Cybergame: wrong credentials");
                        return false;
                    }


                    var result = chatWC.DownloadString(String.Format(chatUrl, String.Empty));
                    
                    kname = Re.GetSubString(result, reKName, 1);
                    khash = Re.GetSubString(result, reKHash, 1);

                    if (String.IsNullOrEmpty(khash))
                    {
                        Debug.Print("Cybergame: couldn't get khash");
                        return false;
                    }

                    chatWC.setCookie("khame", kname, ".cybergame.tv");
                    chatWC.setCookie("khash", khash, ".cybergame.tv");


                    statsWC.Cookies = chatWC.Cookies;
                    loginWC.Cookies = chatWC.Cookies;

                    Debug.Print("Cybergame: connecting web socket");
                    Domain = domain;
                    Port = "9090";
                    Path = String.Format("/{0}/{1}/websocket", random_number(), random_string());
                    Cookies = statsWC.CookiesStrings;
                    Connect();

                    return true;
                }
                catch (Exception e)
                {
                    Debug.Print(String.Format("Cybergame: login exception {0} {1} {2}", chatWC.URL, e.Message, e.StackTrace));
                    return false;
                }
            }
        }
        internal void TryScrapePoolEntries()
        {
            bool entriesKnown = true;
            List<PlayerEntry> newEntries = new List<PlayerEntry>();
            try
            {
                _poolEntriesDirty = false;
                Console.Write("Scraping CBS: ");
                using (CookieAwareWebClient wc = new CookieAwareWebClient())
                {
                    wc.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36");
                    var loginData = new NameValueCollection
                {
                    {"dummy::login_form", "1"},
                    {"form::login_form", "login_form"},
                    {"xurl", @"http://statsnfl.football.cbssports.com/"},
                    {"master_product", "150"},
                    {"vendor", "cbssports"},
                    {"userid", _cbsUser},
                    {"password", _cbsPass},
                    {"_submit", "Sign In"}
                };

                    wc.UploadValues(@"http://www.cbssports.com/login", "POST", loginData);
                    string fullHtml = wc.DownloadString(@"http://statsnfl.football.cbssports.com/office-pool/standings/live");

                    Match data = Regex.Match(fullHtml, @"new CBSi.app.OPMLiveStandings\(.*?({.*?})\s*\);", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    string cleanData = Regex.Replace(data.Groups[1].ToString(), @"""time"":""[^""]*"",?", "", RegexOptions.IgnoreCase | RegexOptions.Singleline);

                    var ser = new JavaScriptSerializer();
                    Dictionary<string, object> result = (Dictionary<string, object>)ser.DeserializeObject(cleanData);

                    if (!((object[])result["teams"]).Any()) return;
                    _poolEntriesDirty = true;
                    foreach (Dictionary<string, object> team in (object[])result["teams"])
                    {
                        if (!team.ContainsKey("picks")) continue;
                        string name = team["name"].ToString();
                        PlayerEntry entry = new PlayerEntry(name);
                        foreach (KeyValuePair<string, object> pick in (Dictionary<string, Object>)team["picks"])
                        {
                            if (pick.Key == "mnf") continue;
                            Dictionary<string, object> pickData = (Dictionary<string, object>)pick.Value;
                            string winner = pickData["winner"].ToString();
                            int points = int.Parse(pickData["weight"].ToString(), CultureInfo.InvariantCulture);
                            entry.AddPick(winner, points);
                        }
                        newEntries.Add(entry);
                        if (!entry.GamePicks.Any()) entriesKnown = false;
                    }
                    Console.Write(newEntries.Count + ".  ");
                }
                PlayerEntries = newEntries;
            }
            catch (Exception ex) 
            {
                Console.WriteLine(ex);
            }
            finally
            {
                _playerEntriesKnown = entriesKnown;
            }
        }
예제 #45
0
 private bool init_goodgame()
 {
     string uri = "http://goodgame.ru/chat/" + channelName;
     CookieContainer cookieContainer = new CookieContainer();
     CookieAwareWebClient cookieAwareWebClient = new CookieAwareWebClient(cookieContainer);
     cookieAwareWebClient.Headers.Add("user-agent", "BlitzChat");
     cookieAwareWebClient.Encoding = Encoding.UTF8;
     try
     {
         string input = cookieAwareWebClient.DownloadString(new Uri(uri, UriKind.RelativeOrAbsolute)).Replace('\n', ' ').Replace('\r', ' ');
         Regex regex = new Regex("BPC=(.*?)\"");
         Match match = regex.Match(input);
         cookieContainer.Add(new Cookie("BPC", match.Groups[1].Value, "/", "goodgame.ru"));
         uri += "?attempt=1";
         input = cookieAwareWebClient.DownloadString(new Uri(uri, UriKind.RelativeOrAbsolute)).Replace('\n', ' ').Replace('\r', ' ');
         regex = new Regex("token.*?\\'(.*?)\\'.*?channelId\\:(.*?)\\,.*?\\'(.*?)\\'", RegexOptions.Multiline);
         match = regex.Match(input);
         if (!match.Success)
         {
             channelId = 0;
             token = "";
             return false;
         }
         token = match.Groups[1].Value;
         channelId = uint.Parse(match.Groups[2].Value);
         //this.channelName = match.Groups[3].Value;
     }
     catch (Exception)
     {
         channelId = 0;
         return false;
     }
     connectSocket();
     return true;
 }
예제 #46
0
 public static string OpenLink(Uri uriObj)
 {
     string html;
     CookieAwareWebClient client = new CookieAwareWebClient();
     client.Proxy = null;
     client.CookieContainer = CC;
     html = client.DownloadString(uriObj);
     return html;
 }
        public IList<Sub> GetCandidateSubs(Video video, bool searchInComments, Dictionary<string, string> cache)
        {
            Console.WriteLine();
            Console.WriteLine("Text used to seach subtitle is: {0}", video.GetSearchString());
            Console.WriteLine("Release Group to match: {0}", video.ReleaseGroup);

            this.login();

            var candidateSubs = new List<Sub>();
            var subdivxClient = new CookieAwareWebClient(this.loginCookies);
            subdivxClient.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))";

            var page = 1;

            while (page > 0)
            {
                var url = this.GetUrl(video.GetSearchString(), page);

                string output;
                if (cache.ContainsKey(url))
                {
                    output = cache[url];
                }
                else
                {
                    output = subdivxClient.DownloadString(url);
                    cache.Add(url, output);
                }

                var doc = new HtmlDocument();
                doc.LoadHtml(output);
                var subsHtmlNodes = doc.DocumentNode.Descendants("div").Where(div => div.GetAttributeValue("id", string.Empty).Equals("buscador_detalle"));

                if (subsHtmlNodes.Count() == 0)
                {
                    page = -1;
                }
                else
                {
                    foreach (var subHtmlNode in subsHtmlNodes)
                    {
                        var subComments = string.Empty;
                        if (searchInComments)
                        {
                            subComments = this.GetSubComments(subdivxClient, subHtmlNode);
                        }

                        var sub = new Sub(subHtmlNode, subComments);

                        if (sub.Matches(video))
                        {
                            candidateSubs.Add(sub);
                        }
                    }
                }

                page++;
            }

            candidateSubs.Sort(new Sub.SubComparer());

            return candidateSubs;
        }
예제 #48
0
 private string login(string username, string password)
 {
     var cookieJar = new CookieContainer();
     client = new CookieAwareWebClient(cookieJar);
     client.Encoding = Encoding.UTF8;
     string response;
     response = client.DownloadString("https://www.stine.uni-hamburg.de/scripts/mgrqispi.dll?APPNAME=CampusNet&PRGNAME=STARTPAGE_DISPATCH&ARGUMENTS=-N000000000000001");
     response = client.DownloadString("https://www.stine.uni-hamburg.de/scripts/mgrqispi.dll?APPNAME=CampusNet&PRGNAME=EXTERNALPAGES&ARGUMENTS=-N000000000000001,-N000265,-Astartseite");
     string postData = "usrname={0}&pass={1}&APPNAME=CampusNet&PRGNAME=LOGINCHECK&ARGUMENTS=clino%2Cusrname%2Cpass%2Cmenuno%2Cmenu_type%2Cbrowser%2Cplatform&clino=000000000000001&menuno=000265&menu_type=classic&browser=&platform=";
     postData = string.Format(postData, HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(password));
     client.Method = "POST";
     response = client.UploadString("https://www.stine.uni-hamburg.de/scripts/mgrqispi.dll", postData);
     string refresh_url = client.ResponseHeaders["REFRESH"].Split(new char[] { ';' }, 2)[1].Split(new char[] { '=' }, 2)[1];
     System.Diagnostics.Debug.Print(refresh_url);
     response = client.DownloadString("https://www.stine.uni-hamburg.de" + refresh_url);
     refresh_url = client.ResponseHeaders["REFRESH"].Split(new char[] { ';' }, 2)[1].Split(new char[] { '=' }, 2)[1];
     System.Diagnostics.Debug.Print(refresh_url);
     response = client.DownloadString("https://www.stine.uni-hamburg.de" + refresh_url);
     richTextBox1.Text = response;
     return response;
 }
예제 #49
-1
파일: WebCore.cs 프로젝트: zuun/wSQL
        public string OpenPage(string url, string loginPage, string userName, string password)
        {
            using (var web = new CookieAwareWebClient())
             {
            var response = web.DownloadString(loginPage);
            web.Headers["Content-Type"] = "application/x-www-form-urlencoded";
            response = web.UploadString(loginPage,
              string.Format("UserName={0}&Password={1}&__RequestVerificationToken=", userName, password) + extractValidationToken(response));

            System.Diagnostics.Debug.WriteLine("OpenPage: " + url);
            response = web.DownloadString(url);
            System.Diagnostics.Debug.WriteLine("OpenPage Done");
            return response;
             }
        }