Welcome to AspAdvice Sign in | Join | Help

HttpWebRequest with JavaScript domain.cookie

I'm trying to use HttpWebRequest to scrape a website.

Unfortunately, this particular site is using BLOCKED SCRIPT document.cookie, to create a cookie. I've been unsuccessful using the CookieContainer to attempt to retrieve the cookie, so I'm now actually searching the html for document.cookie and then manually setting the cookie.

The site is not recognizing the cookie. I believe the problem actually lies in the fact that the domain I'm hitting is a subdomain, for example: https://sub1.sub2.sample.com. The cookie being created via JavaScript simply has domain=".sample.com". When adding a cookie manually, it wants a valid URI, so I've attempted http and https with full domain above and just sample.com, but so far no luck.

This was not the the easiest website to try and scrape.

Published Tuesday, April 26, 2005 10:39 PM by dwalker
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: HttpWebRequest with JavaScript domain.cookie

//please solved my problem this code work nicely at local by create problem at server //please tell me solution or alternate var PreventExitPop = false; function ExitPop() { if(PreventExitPop == false) { PreventExitPop=true; document.getElementById("table").style.display='none'; document.getElementById("table").style.display='block'; scroll(0, 0); return openit('http://demo8.axxiem.com/guildpartners/exit-popup.html'); } } function openit(sURL) { newwindow=open(sURL,"newwin","width=410, height=270"); } // -->
Wednesday, July 09, 2008 8:13 AM by Aryan Rajput

# re: HttpWebRequest with JavaScript domain.cookie

hi, so did you ever manage to execute the javascript in .net. Im facing the same issue with a site that I am scraping, which set cookies via javascript and im looking for a way to execute the function that sets the cookies and intercept that cookie and save it in my cookiecontainer. If you did find a soluiton, id be grateful if you would share it Cheers satyajeeth (at) yahoo.com
Sunday, July 27, 2008 11:08 AM by Satya

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below