screen scrape

May 23 2007 7:03 AM

How do i access a website which needs UserID and Password, I need to capture the cookies so that i can send in another location and get some data.

My code is like this.the URL I have is h5.www5.PP.com/partnerportal/au/en

byte[] ba = System.Text.Encoding.ASCII.GetBytes("userName=bsim&Password=Bimbed&submit=submit"); IS this correct?

HttpWebRequest webRequest=(HttpWebRequest)HttpWebRequest.Create("h5.www5.PP.com/partnerportal/au/en);

webRequest.KeepAlive = false;

webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)";

webRequest.Method = "POST";

webRequest.ContentType ="text/html";

webRequest.ContentLength = ba.Length;

System.IO.Stream requestStream = webRequest.GetRequestStream();

requestStream.Write(ba, 0, ba.Length);

requestStream.Flush();

requestStream.Close();   

webRequest.AllowAutoRedirect = false;

WebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

return webResponse.Headers["Set-Cookie"];

Questions: is the above code correct?

when passing username what wording should i user.

When i click on login it goes through this url

http://h5.www5.pp.com/partnerportal_s/au/en/start.swe?SWECmd=ExecuteLogin&SWEUserName=bsimSWEPassword=%5SBsddeeEnc%2DD%5D6mEMSWFhkG06wxVRWrYzzsj3Z8mfTbicVxHTxZulwS0%3D&SWEAC=SWECmd=GotoView,SWEView=Home+Page+View+(SCW),PageName=Home+ELS,SWERF=1,SWEBU=1

To this URL.

http://h5.www5.pp.com/partnerportal_s/au/en/start.swe?SWECmd=Login&SWEPL=1&SWETS=sc