public async Task CorrectlyGetHtmlWhen_SimulatingWhoScoredSeasonParticipantRequest()
        {
            HttpRequestManager _httpmanager = new HttpRequestManager();
            var realisedcookie = "";
            var cookieResp     = await _httpmanager.Get("https://www.whoscored.com/");

            foreach (var sc in cookieResp.Headers.Where(x => x.Key == "Set-Cookie"))
            {
                foreach (var scv in sc.Value)
                {
                    var v = scv.Split(';')[0];
                    realisedcookie = $"{v}; {realisedcookie}";
                }
            }

            var ctx = new HttpRequestContext();

            ctx.Method    = "GET";
            ctx.Host      = "www.whoscored.com";
            ctx.Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
            ctx.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36";
            ctx.AddHeader("Accept-Encoding", "gzip, deflate, br");
            ctx.AddHeader("Accept-Language", "en-GB,en;q=0.");
            ctx.AddCookie("Cookie", WebUtility.UrlEncode(realisedcookie));
            ctx.Timeout = 120000;
            var detailResp = await _httpmanager.Get("https://www.whoscored.com/Regions/252/Tournaments/2/Seasons/7361", ctx);

            Debug.Write(detailResp.Content.ReadAsStringAsync().Result);
            Assert.IsTrue(detailResp.Content.ReadAsStringAsync().Result.Contains("Premier League tables"));
        }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     string jsonString = @"{""Id"":3,""Message"":""Hello Roger!""}";
     TestObjectDto t = JsonConvert.DeserializeObject<TestObjectDto>(jsonString);
     HttpRequestManager manager = new HttpRequestManager("http://cg.webapi/");
     string response = manager.Get("api/TestApi/GetMessageById/1");
 }
        public WorldOMetersNewsData GetData(params object[] args)
        {
            HttpRequestManager httpRequestManager = new HttpRequestManager(_DataSource.Url);

            try
            {
                this._DataSource.RawData = httpRequestManager.Get(_DataSource.Url);

                WorldOMetersNewsHtmlParser parser = new WorldOMetersNewsHtmlParser();
                WorldOMetersNewsData       data   = parser.ParseData(this._DataSource);

                return(data);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets global data
        /// </summary>
        /// <param name="args">Only 1 /2  parameter (the country as a string and the region as a string), or no parameters should be passed</param>
        /// <returns>The data requested</returns>
        public Covid19Data GetData(params object[] args)
        {
            string endPoint = args != null && args.Length > 0 ? $"country/{args[0].ToString().Replace("country", string.Empty).Replace("//", "/")}" : string.Empty;

            HttpRequestManager httpRequestManager = new HttpRequestManager($"https://www.worldometers.info/coronavirus/{endPoint}");

            try
            {
                this._DataSource.RawData = httpRequestManager.Get(endPoint);
                WorldOMetersDataHtmlParser parser = new WorldOMetersDataHtmlParser();

                Covid19Data data = parser.ParseData(this._DataSource);
                data.Country = args != null && args.Length > 0 ? args[0].ToString() : "GLOBAL";
                data.Region  = args != null && args.Length > 1 ? args[1].ToString() : data.Country;

                return(data);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 5
0
        private async void Continue_OnClick(object sender, RoutedEventArgs e)
        {
            // Get GUID again
            var guid = (new ActivationManager()).GetMachineGuid();

            // Get ikariam base URI
            var requestManager = new HttpRequestManager();
            var uri            = string.Format("https://winika.nxu.hu/client-auth/{0}", guid.ToUpper());

            string response;

            try
            {
                response = await requestManager.Get(uri);
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex.Message);
                return;
            }

            // Parse as JSON
            var data = JObject.Parse(response);

            if ((bool)data["success"] != true)
            {
                // Error
                this.ShowErrorMessage((string)data["errormessage"]);
                return;
            }

            // Save base URI and continue
            var baseuri     = (string)data["data"]["baseuri"];
            var useragent   = (string)data["data"]["useragent"];
            var loginWindow = new LoginWindow(baseuri, useragent);

            loginWindow.Show();
            this.Close();
        }
Exemplo n.º 6
0
        public GitHubEntityData GetData(params object[] args)
        {
            GitHubEntityData gitHubCountriesData = new GitHubEntityData();

            try
            {
                foreach (var githubDataSrc in _GitHubSources)
                {
                    HttpRequestManager httpRequestManager = new HttpRequestManager(githubDataSrc.Url);
                    githubDataSrc.RawData = httpRequestManager.Get(githubDataSrc.Url);
                }

                GitHubTimeSeriesCSVParses csvParser = new GitHubTimeSeriesCSVParses();
                gitHubCountriesData = csvParser.ParseData(_DataSource);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(gitHubCountriesData);
        }
        public RssFeed GetData(params object[] args)
        {
            RssFeed rssFeed = new RssFeed();

            try
            {
                foreach (var rssFeedSrc in _DataSource.Sources)
                {
                    HttpRequestManager httpRequestManager = new HttpRequestManager(rssFeedSrc.Url);
                    rssFeedSrc.RawData = httpRequestManager.Get(rssFeedSrc.Url);
                }

                RssFeedXmlSerializer xmlSerializer = new RssFeedXmlSerializer();
                rssFeed.BbcFeed     = xmlSerializer.DeserializeFeed(_DataSource.Sources.Where(s => s.Id == RssSource.BBC.ToString()).FirstOrDefault().RawData);
                rssFeed.CnnFeed     = xmlSerializer.DeserializeFeed(_DataSource.Sources.Where(s => s.Id == RssSource.CNN.ToString()).FirstOrDefault().RawData);
                rssFeed.ReutersFeed = xmlSerializer.DeserializeFeed(_DataSource.Sources.Where(s => s.Id == RssSource.Reuters.ToString()).FirstOrDefault().RawData);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(rssFeed);
        }