Esempio n. 1
0
 void MQOEvents_onAttack(object obj)
 {
     if (!FightWebClient.IsBusy)
     {
         Uri tempUri = new Uri("http://midenquest.com/useSkill.aspx?id=1&ta=" + obj.ToString());
         FightWebClient.DownloadString(tempUri);
     }
 }
Esempio n. 2
0
 void MQOEvents_onStopWork(object obj)
 {
     if (!SkillWebClient.IsBusy)
     {
         Uri tempUri = new Uri("http://midenquest.com/useWork.aspx?stop=4&null=&sid=" + GetSID().ToString());
         SkillWebClient.DownloadString(tempUri);
     }
 }
Esempio n. 3
0
        public void run()
        {
            WebRequest.DefaultWebProxy = null;
            ServicePointManager.DefaultConnectionLimit = 80;

            using (
                var session = TheCouch.CreateSession("cruiseme", new Uri("http://127.0.0.1:5984"))
                )
            {
                var stopWatch = new Stopwatch();

                using (var webClient = new WebClientEx())
                {
                    // webClient.DownloadString("http://127.0.0.1:5984/cruiseme/_design/destinations/_view/by_id");
                    webClient.Proxy = null;
                    stopWatch.Reset();
                    stopWatch.Start();
                    webClient.DownloadString("http://127.0.0.1:5984/cruiseme/_design/destinations/_view/by_id");
                    stopWatch.Stop();

                    Console.WriteLine("Total time taken: {0}ms to fetch raw", stopWatch.ElapsedMilliseconds);

                    stopWatch.Reset();
                    stopWatch.Start();
                    webClient.DownloadString("http://127.0.0.1:5984/cruiseme/_design/destinations/_view/by_id");
                    stopWatch.Stop();

                    Console.WriteLine("Total time taken: {0}ms to fetch raw", stopWatch.ElapsedMilliseconds);
                }

                using (var webClient = new WebClientEx())
                {
                    // webClient.DownloadString("http://127.0.0.1:5984/cruiseme/_design/destinations/_view/by_id");

                    stopWatch.Reset();
                    stopWatch.Start();
                    webClient.DownloadString("http://127.0.0.1:5984/cruiseme/_design/destinations/_view/by_id");
                    stopWatch.Stop();

                    Console.WriteLine("Total time taken: {0}ms to fetch raw", stopWatch.ElapsedMilliseconds);

                    stopWatch.Reset();
                    stopWatch.Start();
                    webClient.DownloadString("http://127.0.0.1:5984/cruiseme/_design/destinations/_view/by_id");
                    stopWatch.Stop();

                    Console.WriteLine("Total time taken: {0}ms to fetch raw", stopWatch.ElapsedMilliseconds);
                }
            }
        }
        private void GetVerInfo()
        {
            string      sRet       = null;
            WebClientEx sckVerInfo = new WebClientEx();

            sckVerInfo.KeepAlive = false;
            if (lblBETA.Visible)
            {
                sRet = sckVerInfo.DownloadString("http://update.realityripple.com/Satellite_Restriction_Tracker/infob");
            }
            else
            {
                sRet = sckVerInfo.DownloadString("http://update.realityripple.com/Satellite_Restriction_Tracker/info");
            }
            SetVerInfo(sRet);
        }
Esempio n. 5
0
    static private (Version, string) GetVersionAndChecksum(WebClientEx client, bool useGitHub)
    {
        SystemManager.CheckServerCertificate(useGitHub ? Globals.CheckUpdateGitHubURL : Globals.CheckUpdateURL, useGitHub, true);
        List <string> lines;

        try
        {
            string path = useGitHub ? Globals.CheckUpdateGitHubURL : Globals.CheckUpdateURL;
            lines = client.DownloadString(path).SplitNoEmptyLines(useGitHub).Take(2).ToList();
        }
        catch (Exception ex)
        {
            throw new WebException(SysTranslations.CheckUpdateReadError.GetLang(ex.Message));
        }
        LoadingForm.Instance.DoProgress();
        var list = new NullSafeOfStringDictionary <string>();

        foreach (string line in lines)
        {
            var parts = line.Split(':');
            if (parts.Length != 2)
            {
                continue;
            }
            list.Add(parts[0].Trim(), parts[1].Trim());
        }
        string fileVersion  = list["Version"];
        string fileChecksum = list["Checksum"];

        if (fileVersion.IsNullOrEmpty() || fileChecksum.IsNullOrEmpty())
        {
            throw new WebException(SysTranslations.CheckUpdateFileError.GetLang(lines.AsMultiLine()));
        }
        var     partsVersion = fileVersion.Split('.');
        Version version;

        try
        {
            version = partsVersion.Length switch
            {
                2 => new Version(Convert.ToInt32(partsVersion[0]),
                                 Convert.ToInt32(partsVersion[1])),
                3 => new Version(Convert.ToInt32(partsVersion[0]),
                                 Convert.ToInt32(partsVersion[1]),
                                 Convert.ToInt32(partsVersion[2])),
                4 => new Version(Convert.ToInt32(partsVersion[0]),
                                 Convert.ToInt32(partsVersion[1]),
                                 Convert.ToInt32(partsVersion[2]),
                                 Convert.ToInt32(partsVersion[3])),
                _ => throw new ArgumentException(SysTranslations.CheckUpdateFileError.GetLang(lines.AsMultiLine())),
            };
        }
        catch (Exception ex)
        {
            throw new WebException(SysTranslations.CheckUpdateFileError.GetLang(lines.AsMultiLine()) + Globals.NL2 +
                                   ex.Message);
        }
        LoadingForm.Instance.DoProgress();
        return(version, fileChecksum);
    }
Esempio n. 6
0
 public static string DownloadStringWithCookie(string link, CookieContainer cookie)
 {
     using (var wc = new WebClientEx(cookie))
     {
         return(wc.DownloadString(link));
     }
 }
Esempio n. 7
0
        void MQOEvents_onRequestLogin(object obj)
        {
            MQOEvents.TestEvent("Loggin requested");
            if (!LoginWebClient.IsBusy)
            {
                string[] parsed = obj.ToString().Split(',');

                var values = new NameValueCollection
                {
                    { "User", parsed[0] },
                    { "Pass", parsed[1] },
                };

                // Upload values
                string tempStringUri = "http://midenquest.com/UserLogin.aspx";
                LoginWebClient.UploadValues(tempStringUri, values);

                // Get Character Page
                string charPage = LoginWebClient.DownloadString("http://midenquest.com/UserCharacterSelection.aspx");

                SetCookies();

                MQOEvents.OpenCharacterSelection(charPage);
            }
            else
            {
                MQOEvents.TestEvent("Busy");
            }
        }
        public static void Initialize()
        {
            ImageLoader.RegisterSpecialResolverTable("pixiv", uri =>
            {
                try
                {
                    var builder = new UriBuilder(uri)
                    {
                        Scheme = "http"
                    };
                    uri = builder.Uri;
                    using (var wc = new WebClientEx())
                    {
                        wc.CookieContainer = new CookieContainer();

                        var src   = wc.DownloadString(uri);
                        var match = PixivRegex.Match(src);
                        if (match.Success)
                        {
                            wc.Referer = uri.OriginalString;
                            return(wc.DownloadData(match.Groups[1].Value));
                        }
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
                return(new byte[0]);
            });
        }
Esempio n. 9
0
        private bool CheckUrlContent()
        {
            bool isok = true;

            System.Threading.Thread.Sleep(1000);
            try {
                var webClient = new WebClientEx();
                foreach (var checkUrl in CheckUrls)
                {
                    webClient.ResetHeaders();
                    if (string.IsNullOrEmpty(checkUrl.ContainString))
                    {
                        webClient.DownloadData(checkUrl.Url);
                    }
                    else
                    {
                        var str = webClient.DownloadString(checkUrl.Url);
                        if (str.Contains(checkUrl.ContainString) == false)
                        {
                            isok = false;
                            break;
                        }
                    }
                }
            } catch (Exception e) {
                isok = false;
            }
            return(isok);
        }
Esempio n. 10
0
        public VersionPair CheckUpdates(GameModel model)
        {
            if (model == null)
            {
                throw new ArgumentException("model argument cannot be null");
            }
            string versionFile = ConfigurationManager.GetLocalVersionFile(model);

            if (File.Exists(ConfigurationManager.GetLocalVersionFile(model)))
            {
                int verCurrent = -1;
                int verRemote  = -1;

                using (StreamReader streamReader = new StreamReader(versionFile)) {
                    verCurrent = GetVersion(streamReader.ReadToEnd());
                }

                using (WebClientEx webClient = new WebClientEx()) {
                    string result;
                    try {
                        result    = webClient.DownloadString(ConfigurationManager.GetConfiguration(model).VersionRemoteURL);
                        verRemote = GetVersion(result);
                    } catch {
                        return(null);
                    }

                    if (verRemote < 0 || verCurrent < 0)
                    {
                        return(null);
                    }
                    return(new VersionPair(verCurrent, verRemote));
                }
            }
            return(null);
        }
Esempio n. 11
0
 void MQOEvents_onOpenChest(object obj)
 {
     if (!MainWebClient.IsBusy)
     {
         Uri tempUri = new Uri("http://midenquest.com/getCharacterSheet.aspx?open=1");
         MainWebClient.DownloadString(tempUri);
     }
 }
Esempio n. 12
0
        //private string WebPost(string url, string json)
        //{
        //    WebClientEx web = new WebClientEx();
        //    web.ResetHeaders();
        //    //web.Headers.Add();
        //    web.Encoding = Encoding.UTF8;
        //    return web.UploadString(url, "POST", json);
        //}
        //private string WebPost(string url, object obj)
        //{
        //    var json = JsonConvert.SerializeObject(obj);
        //    WebClientEx web = new WebClientEx();
        //    web.ResetHeaders();
        //    web.Encoding = Encoding.UTF8;
        //    return web.UploadString(url, "POST", json);
        //}
        private string WebGet(string url)
        {
            WebClientEx web = new WebClientEx();

            web.ResetHeaders();
            web.Encoding = Encoding.UTF8;
            return(web.DownloadString(url));
        }
Esempio n. 13
0
        public List <T> LoadUrl(string address)
        {
            WebClientEx webClient = new WebClientEx();

            webClient.ResetHeaders();
            var html = webClient.DownloadString(address);

            return(LoadData(html));
        }
Esempio n. 14
0
        public async Task <IActionResult> Login(string ssoId, string token)
        {
            //get user data TODO
            var loginPage = _configuration["LoginPage"];
            var PostPage  = _configuration["PostPage"];

            ApiService = _configuration["ApiUrl"];

            var url   = ApiService + "api/user?ssoId=" + ssoId;
            var model = new TrendMicroLoginModel();



            using (var clientapi = new HttpClient())
            {
                var uri = new Uri(url);
                clientapi.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", token));

                var response = await clientapi.GetAsync(uri);

                var json = await response.Content.ReadAsStringAsync(); //This is working

                // var Userdata = JsonConvert.DeserializeObject<User>(json);
                var obj = JsonConvert.DeserializeObject <RootObject>(json);
                model.username = obj.User.applicationLoginName;
                model.password = obj.User.applicationPassword;
            }


            var client = new WebClientEx();
            var data   = client.DownloadString(loginPage);

            var doc = new HtmlDocument();

            doc.LoadHtml(data);

            var AuthState = doc.GetElementbyId("AuthState").GetAttributeValue("value", "");

            var cookies = CookieContainerExtension.GetAllCookies(client.CookieContainer).ToList();

            foreach (var c in cookies)
            {
                //var cookie = new HttpCookie(c.Name, c.Value);
                var option = new CookieOptions();
                option.Domain  = c.Domain;
                option.Expires = DateTime.Now.AddMinutes(5);

                Response.Cookies.Append(c.Name, c.Value, option);
                // Response.Cookies.Add(cookie);
            }

            model.LoginPage = loginPage;
            model.PostPage  = PostPage;
            model.AuthState = AuthState;

            return(View(model));
        }
Esempio n. 15
0
        private void backupGallery(string urlbase)
        {
            if (textBox1.Text != "")
            {
                Directory.CreateDirectory(path + "/Gallery/");
                WebClientEx wb = new WebClientEx();
                String src = "";
                String pages = "";
                Regex nbPages = new Regex("@?page=[0-9]*\">[0-9]*</a><a class=\"noborder\"");
                Regex nom = new Regex("_blank\" title=\".*\"");
                Regex urls = new Regex("\\('[A-Za-z0-9]*'\\)\"");
                src = wb.DownloadString("http://puush.me/login/go/?k=" + key);
                src = wb.DownloadString("http://puush.me" + urlbase);

                if (nbPages.IsMatch(src))
                {
                    pages = nbPages.Match(src).ToString();
                    pages = pages.Remove(pages.LastIndexOf('>'));
                    pages = pages.Remove(pages.LastIndexOf('<'));
                    pages = pages.Substring(pages.IndexOf('>') + 1);
                }
                else
                {
                    pages = "1";
                }

                for (int i = 0; i < int.Parse(pages); i++)
                {
                    src = wb.DownloadString("http://puush.me/" + urlbase + "&page=" + (i + 1));
                    for (int j = 0; j < urls.Matches(src).Count; j++)
                    {
                        String name = nom.Matches(src)[j].ToString();
                        String url = urls.Matches(src)[j].ToString();
                        name = name.Remove(0, 15);
                        name = name.Remove(name.LastIndexOf('(') - 1);
                        url = url.Remove(0, 2);
                        url = url.Remove(url.Length - 3);

                        wb.DownloadFile("http://puu.sh/" + url, path + "/Gallery/" + name);
                    }
                }
            }
        }
Esempio n. 16
0
 protected String[] GetFormats(String tenantId, String jobId)
 {
     using (WebClientEx client = new WebClientEx())
     {
         //TODO: use round robin if a document store is down.
         var url    = GetBlobUriForJobFormats(tenantId, jobId);
         var result = client.DownloadString(url);
         return(JsonConvert.DeserializeObject <String[]>(result));
     }
 }
Esempio n. 17
0
 private string LoadResource(HPage page)
 {
     using (var webClientEx = new WebClientEx(Cookies))
     {
         string url = page.Juice(Hotel) + (page == HPage.Home ? PlayerName : string.Empty);
         webClientEx.Headers["User-Agent"] = SKore.ChromeAgent;
         string body = webClientEx.DownloadString(url);
         HandleResource(page, ref body);
         return(body);
     }
 }
Esempio n. 18
0
        protected T Get <T>(string url, int timeout = Config.TIME_OUT) where T : class
        {
            WebClientEx web = new WebClientEx();

            web.ResetHeaders();
            web.Encoding = Encoding.UTF8;
            web.SetTimeOut(timeout);
            var json = web.DownloadString(url);

            return(Deserialize <T>(json));
        }
Esempio n. 19
0
        public string GetResource(HPage page)
        {
            using (var webclientEx = new WebClientEx(Cookies))
            {
                string pageUrl = page.Juice(Hotel);
                webclientEx.Headers["User-Agent"] = SKore.ChromeAgent;
                if (page == HPage.Client)
                {
                    pageUrl = (_clientUrl ??
                               (_clientUrl = webclientEx.DownloadString(pageUrl).Split('"')[3]));

                    webclientEx.Proxy = null;
                }
                else if (page == HPage.Profile)
                {
                    pageUrl += PlayerName;
                }

                return(ProcessResource(webclientEx.DownloadString(pageUrl)));
            }
        }
Esempio n. 20
0
        private static ResourceResult CheckResource()
        {
            var fileInfo = new FileInfo(ResourcePath);

            if (!fileInfo.Exists)
            {
                return(ResourceResult.NeedToDownload);
            }

            try
            {
                using (var wc = new WebClientEx())
                {
                    // 파일 사이즈 비교
                    wc.Method = "HEAD";
                    wc.DownloadData(ResourceUrl);
                    if (fileInfo.Length != wc.ContentLength)
                    {
                        return(ResourceResult.NeedToDownload);
                    }

                    if (fileInfo.Exists)
                    {
                        // 파일 해싱 비교
                        string hashCurrent, hashRemote;

                        using (var md5 = MD5.Create())
                            using (var file = File.OpenRead(ResourcePath))
                                hashCurrent = BitConverter.ToString(md5.ComputeHash(file)).Replace("-", "").ToLower();

                        wc.Method  = null;
                        hashRemote = wc.DownloadString(ResourceHash).ToLower();

                        if (!string.IsNullOrWhiteSpace(hashRemote) && hashRemote.StartsWith(hashCurrent))
                        {
                            return(ResourceResult.Success);
                        }
                    }
                }
            }
            catch (WebException ex)
            {
                Sentry.Error(ex);
                return(ResourceResult.NetworkError);
            }
            catch (Exception ex)
            {
                Sentry.Error(ex);
                return(ResourceResult.UnknownError);
            }

            return(ResourceResult.NeedToDownload);
        }
Esempio n. 21
0
 private string LoadResource(HPages Page)
 {
     using (WebClientEx WC = new WebClientEx(Cookies))
     {
         string Body = string.Empty;
         string URL  = Page.Juice(Hotel) + (Page == HPages.Home ? PlayerName : string.Empty);
         WC.Headers["User-Agent"] = SKore.ChromeAgent;
         Body = WC.DownloadString(URL);
         HandleResource(Page, ref Body);
         return(Body);
     }
 }
Esempio n. 22
0
        } // End Function GetFormValues

        public static void Test()
        {
            string projName = RedmineMailService.SecretManager.GetSecret <string>("SAP_Project_Name");
            string url      = RedmineMailService.SecretManager.GetSecret <string>("URL", projName);
            string username = RedmineMailService.SecretManager.GetSecret <string>("Username", projName);
            string password = RedmineMailService.SecretManager.GetSecret <string>("Password", projName);

            string base64Creds      = System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(username + ":" + password));
            string basicCredentials = "Basic " + base64Creds;


            using (WebClientEx wc = new WebClientEx())
            {
                wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36");
                wc.Headers.Add("Authorization", basicCredentials);


                // Request 1
                string         redirect = wc.DownloadString(url);
                RedirectValues rv1      = GetFormValues(redirect);

                byte[] retValue = wc.UploadValues(rv1.Action, rv1.Method, rv1.PostValues);
                string resp     = System.Text.Encoding.UTF8.GetString(retValue);
                System.Console.WriteLine(resp);


                RedirectValues rv2 = GetFormValues(resp);
                System.Console.WriteLine(rv2);
                // Request 2
                wc.Headers["referer"]        = url;
                rv2.PostValues["j_username"] = username;
                rv2.PostValues["j_password"] = password;
                // string url2 = "https://accounts.sap.com" + rv2.Action;
                System.Uri baseUri = new System.Uri(rv1.Action, System.UriKind.Absolute);
                string     url2    = baseUri.Scheme + "://" + baseUri.Authority + rv2.Action;

                byte[] loginRetValue    = wc.UploadValues(url2, rv2.Method, rv2.PostValues);
                string strLoginRetValue = System.Text.Encoding.UTF8.GetString(loginRetValue);
                System.Console.WriteLine(strLoginRetValue);
                System.Console.WriteLine(wc.CookieContainer);


                RedirectValues rv3 = GetFormValues(strLoginRetValue);
                System.Console.WriteLine(rv3);
                // Request 3
                wc.Headers["referer"] = url2;
                byte[] retValueRedirect  = wc.UploadValues(rv3.Action, rv3.Method, rv3.PostValues);
                string strRedirectResult = System.Text.Encoding.UTF8.GetString(retValueRedirect);
                System.Console.WriteLine(strRedirectResult);
            } // End Using wc
        }     // End Sub Test
Esempio n. 23
0
    static void Main()
    {
        using (var client = new WebClientEx())
        {
            var response1 = client.DownloadString("https://myJazzServer.com:9092/jazz/authenticated/identity");

            var data = new NameValueCollection
            {
                { "j_username", "myUser" },
                { "j_password", "MyPass" },
            };
            var response2 = client.UploadValues("https://myJazzServer.com:9092/jazz/authenticated/j_security_check", data);
            Console.WriteLine(Encoding.Default.GetString(response2));
        }
    }
Esempio n. 24
0
 private static string GetSourceForMyShowsPage(string usr, string psw)
 {
     using (var client = new WebClientEx())
     {
         var values = new NameValueCollection
         {
             { "login_name", usr },
             { "login_pass", psw },
         };
         // Authenticate
         client.UploadValues("http://admin.anahit.fr/Account/Login", values);
         // Download desired page
         return(client.DownloadString("http://admin.anahit.fr/"));
     }
 }
Esempio n. 25
0
 static string GetSourceForMyShowsPage()
 {
     using (var client = new WebClientEx())
     {
         var values = new NameValueCollection
         {
             { "login_name", "xxx" },
             { "login_pass", "xxxx" },
         };
         // Authenticate
         client.UploadValues("http://www.tvrage.com/login.php", values);
         // Download desired page
         return(client.DownloadString("http://www.tvrage.com/mytvrage.php?page=myshows"));
     }
 }
        private static void GetVoucher(string phoneNumber)
        {
            var r = new Random(DateTime.Today.Millisecond);

            for (var i = 0; i < 1000; i++)
            {
                var cookieContainer = new CookieContainer();
                using (var webClientEx = new WebClientEx(cookieContainer))
                {
                    try
                    {
                        webClientEx.DownloadString(StarbucksCouponUrl);
                    }
                    catch (Exception)
                    {
                        // ignored
                    }

                    var payload =
                        $"mobilephone_1={phoneNumber}&mobilephone_2={phoneNumber}&mobilephone_3={phoneNumber}&mobilephone_4={phoneNumber}&question_91=326&question_92=330&question_97=350";

                    webClientEx.Headers.Add("Accept", ApplicationType);
                    webClientEx.Headers.Add("Content-Type", ContentType);
                    webClientEx.Headers.Add("Referer", StarbucksCouponUrl);
                    webClientEx.Headers.Add("Origin", StarbucksOrigin);
                    webClientEx.Headers.Add("User-Agent", UserAgent);

                    try
                    {
                        Console.Write("Request#" + (i + 1) + " Result...");
                        var result = JObject.Parse(webClientEx.UploadString(StarbucksCouponUrl, payload));
                        if (result["status"].ToString() == "1")
                        {
                            Console.WriteLine("Success...");
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                        Console.WriteLine("Failed...");
                    }

                    Thread.Sleep(r.Next(100, 300));
                }
            }
        }
Esempio n. 27
0
        static void downloadAllSpreedSheetFiles()
        {
            fileUrls = new Dictionary <string, string>();
            int    counter = 0;
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader(@"C:\Users\shahnewaz\Documents\GapMinder\config.txt");
            while ((line = file.ReadLine()) != null)
            {
                counter++;
                string[] arr = line.Split('\t');
                if (arr[5].StartsWith("http"))
                {
                    string url = @"{0}&usp=sharing&output=csv"; // REPLACE THIS WITH YOUR URL
                    url = String.Format(url, arr[5].Trim());

                    fileUrls.Add(arr[0].Trim(), arr[5].Trim());

                    WebClientEx wc = new WebClientEx(new CookieContainer());
                    wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0");
                    wc.Headers.Add("DNT", "1");
                    wc.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                    wc.Headers.Add("Accept-Encoding", "deflate");
                    wc.Headers.Add("Accept-Language", "en-US,en;q=0.5");

                    string path = @"C:\Users\shahnewaz\Documents\GapMinder\Output\" + arr[0].Trim() + "";
                    //path += (arr[1].Equals("") || arr[1].StartsWith("---")) ? counter + "" : arr[1].Trim();
                    path += ".csv";

                    if (File.Exists(path))
                    {
                        continue;
                    }
                    var outputCSVdata = wc.DownloadString(url);
                    using (StreamWriter sw = (File.Exists(path)) ? File.AppendText(path) : File.CreateText(path))
                    {
                        sw.WriteLine(outputCSVdata);
                    }
                }
            }

            file.Close();
        }
Esempio n. 28
0
        public string WebDownloadStringSync(string url)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);

                WebClientEx ws = new WebClientEx();
                ws.Encoding = Encoding.UTF8;
                return(ws.DownloadString(new Uri(url)));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
                return(string.Empty);
            }
        }
Esempio n. 29
0
        public string WebDownloadStringSync(string url)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol();

                WebClientEx ws = new WebClientEx();

                return(ws.DownloadString(new Uri(url)));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
                return(string.Empty);
            }
        }
Esempio n. 30
0
        private void DoXMLRequest(NameValueCollection formData, string address)
        {
            using (var webClientEx = new WebClientEx(Cookies))
            {
                webClientEx.Headers["X-App-Key"]  = CsrfToken;
                webClientEx.Headers["User-Agent"] = SKore.ChromeAgent;
                webClientEx.Headers["Referer"]    = Hotel.ToUrl(true) + "/client";

                if (formData != null)
                {
                    webClientEx.UploadValues(address, "POST", formData);
                }
                else
                {
                    webClientEx.DownloadString(address);
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Sets header and returns un-gziped page source.
        /// </summary>
        /// <param name="url">Page to download source from</param>
        /// <returns></returns>
        private static string Request(string url)
        {
            Client.TimeOut = int.MaxValue;

            int tries = 0;

            do
            {
                try
                {
                    Client.Headers["User-Agent"] = UserAgent;
                    return(Client.DownloadString(url));
                } catch (Exception ex) when(tries++ < 3)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine($"Tries [{tries}/3]...");
                }
            } while (true);
        }
        public void event_btnUpload_Activated(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty (txtUserName.StringValue) || string.IsNullOrEmpty (txtPassWord.StringValue)) {
                var alert = new NSAlert {
                    MessageText = "Username or password empty.",
                    AlertStyle = NSAlertStyle.Informational
                };

                alert.AddButton ("Ok");

                alert.RunModal();
                return;
            }

            FileInfo fInfo = new FileInfo(txtFullSceneName.StringValue);
            long numBytes = fInfo.Length;

            FileStream fStream = new FileStream(txtFullSceneName.StringValue, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fStream);

            FormUpload.FileParameter fp = new FormUpload.FileParameter (br.ReadBytes((int)numBytes),
                Path.GetFileName (txtFullSceneName.StringValue),
                "application/octet-stream");

            br.Close();
            fStream.Close();

            string releaseType = string.Empty;
            if (cmbType.StringValue == "App")
                releaseType = "1";
            if (cmbType.StringValue == "Game")
                releaseType = "2";

            var client = new WebClientEx ();
            var values = new NameValueCollection
            {
                { "username", txtUserName.StringValue },
                { "password", txtPassWord.StringValue },
            };

            // Authenticate
            client.UploadValues("https://mac-torrents.me/login.php", values);
            string tempResponse = client.DownloadString ("https://mac-torrents.me/upload.php");

            string searchFor = "<input type=\"hidden\" name=\"auth\" value=\"";
            int indexSearchFor = tempResponse.IndexOf (searchFor) + searchFor.Length;
            string authString = tempResponse.Substring (indexSearchFor, 32);

            // Upload torrent
            Dictionary<string, object> paramsDic = new Dictionary<string, object> ();
            paramsDic.Add ("submit", "true");
            paramsDic.Add ("auth", authString);
            paramsDic.Add ("type", releaseType);
            paramsDic.Add ("title", txtTitleCode.StringValue);
            paramsDic.Add ("tags", txtTagsCode.StringValue);
            paramsDic.Add ("image", txtImageCode.StringValue);
            paramsDic.Add ("desc", txtDescriptionCode.Value);
            paramsDic.Add ("file_input", fp);

            if (cmbComp.StringValue == "10.6") {
                paramsDic.Add ("macos[]", new string[] {"1", "2", "3", "4"});
            }
            if (cmbComp.StringValue == "10.7")
            {
                paramsDic.Add ("macos[]", new string[] {"2", "3", "4"});
            }
            if (cmbComp.StringValue == "10.8")
            {
                paramsDic.Add ("macos[]", new string[] {"3", "4"});
            }
            if (cmbComp.StringValue == "10.9")
            {
                paramsDic.Add ("macos[]", "4");
            }
            //Upload torrent
            FormUpload.MultipartFormDataPost (
                "https://mac-torrents.me/upload.php",
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) " +
                    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36",
                paramsDic,
                client.CookieContainer);

            try
            {
                tempResponse = client.DownloadString ("https://mac-torrents.me/logout.php?auth=" + authString);
            } catch {
            }

            txtNfoFilename.StringValue = "";
            txtDescription.Value = "";
            txtDescriptionCode.Value = "";
            txtTagsCode.StringValue = "";
            txtImageCode.StringValue = "";

            var alertEnd = new NSAlert {
                MessageText = "Done!",
                AlertStyle = NSAlertStyle.Informational
            };

            alertEnd.AddButton ("Ok");

            alertEnd.RunModal();
        }
Esempio n. 33
0
        private void button2_Click(object sender, EventArgs e)
        {
            WebClientEx wb = new WebClientEx();
            Regex r = new Regex(@"/account/\?pool=[0-9]*");
            String src = wb.DownloadString("http://puush.me/login/go/?k=" + key);

            if (checkBoxPublic.Checked)
            {
                backupPublic(r.Matches(src)[0].ToString());
            }
            if (checkBoxPrivate.Checked)
            {
                backupPrivate(r.Matches(src)[1].ToString());
            }
            if (checkBoxGallery.Checked)
            {
                backupGallery(r.Matches(src)[2].ToString());
            }
        }