Ejemplo n.º 1
0
        public IWebPage GetPageWithAdditionalCookies(Uri uri, CookieCollection cookies)
        {
            var container = new CookieContainer();

            container.Add(cookies);

            var content       = _cookieAwareWebClient.DownloadString(uri);
            var uriOfResponse = _cookieAwareWebClient.UriAfterRedirect;
            var page          = MakeWebPageFromHtml(content, _cookieAwareWebClient.ResponseHeaders[HttpResponseHeader.SetCookie], uriOfResponse, _cookieAwareWebClient.Request);

            return(page);
        }
Ejemplo n.º 2
0
        //Texas
        public static string GetUsingClient(string strPageUrl, WebProxy proxy)
        {
            CookieAwareWebClient objClient = new CookieAwareWebClient();

            objClient.Proxy = proxy;
            objClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            //objClient.Headers.Add("user-agent", "Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 58.0.3029.110 Safari / 537.36)");


            Uri target = new Uri(strPageUrl);

            Cookie c1 = new Cookie();

            objClient.CookieContainer.Add(new Cookie("ASPSESSIONIDQECTSQDT", "PCPGAFKBOKPIPIDHPHMAJJDG")
            {
                Domain = target.Host
            });
            objClient.CookieContainer.Add(new Cookie("_ga", "GA1.3.155819001.1498682767")
            {
                Domain = target.Host
            });
            objClient.CookieContainer.Add(new Cookie("_gid", "GA1.3.1150811410.1498682767")
            {
                Domain = target.Host
            });

            string strSource = string.Empty;

            strSource = objClient.DownloadString(strPageUrl);
            return(strSource);
        }