Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 19th, 2008, 08:56 AM
Registered User
Join Date: Sep 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to indiandotnet
Default Parsing and Executing js in class library project


I am writing a bot for one site.When i have gone through the html it contains 4-5 js file which are creating the cookies by various complex ways.Now i need to those cookies to post in to next request but i am not getting those.Even google analytics js put some cookies which are not visible also.The only way i can see those are by fiddler and paros but not getting in HTTPResponse's cookies.I have used JScriptCodeProvider but it is of no use because it takes syntax diffrent than javascript and i can not make it for thousands of lines.Actually i need to post image to that site.My Code is.....

HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(loginURL);
            httpWebRequest.Method = "Get";
            httpWebRequest.KeepAlive = true;
            httpWebRequest.AllowAutoRedirect = true;
            httpWebRequest.Accept = @"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";

            httpWebRequest.Headers.Add("Accept-Encoding", "gzip, deflate"); //lets try accepting gzip
            httpWebRequest.Headers.Add("UA-CPU", "x86");
            httpWebRequest.Headers.Add("Accept-Language", "en-us");
            httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; Zune 2.0; .NET CLR 3.0.04506.648)";

            httpWebRequest.CookieContainer = new CookieContainer();

            HttpWebResponse webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            //webResponse.ContentEncoding = "Unicode";

            Stream responseStream = webResponse.GetResponseStream();

            if (webResponse.ContentEncoding.ToLower().Contains("g zip"))
                responseStream = new GZipStream(responseStream, CompressionMode.Decompress);
            else if (webResponse.ContentEncoding.ToLower().Contains("d eflate"))
                responseStream = new DeflateStream(responseStream, CompressionMode.Decompress);

            Encoding encoding=Encoding.GetEncoding("utf-8");
            //string links = hu.Process(responseStream,new Uri(loginURL));
            StreamReader responseReader = new StreamReader(responseStream, encoding);
            string responseString = responseReader.ReadToEnd();
            webResponse.Cookies.Add(httpWebRequest.CookieConta iner.GetCookies(httpWebRequest.RequestUri));

Please help me regarding the issue..

Thanks in advance!


Similar Threads
Thread Thread Starter Forum Replies Last Post
zxml.js library for firefox 3.0 manahual BOOK: Professional Ajax ISBN: 978-0-471-77778-6 4 March 2nd, 2010 04:59 AM
Invoking selection.js library file in static page Manoah Javascript 2 September 2nd, 2008 04:05 AM
Regarding Class Library (.dll) from class file manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 March 3rd, 2006 07:32 AM
Controls New Class Library project page 60??? Ghistos BOOK: ASP.NET Website Programming Problem-Design-Solution 5 July 27th, 2004 10:40 PM
New project, VB.NET Class Library eirikr BOOK: ASP.NET Website Programming Problem-Design-Solution 0 June 11th, 2003 05:25 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.