Steve H.
Steve H.

Reputation: 3363

Load and Use a Web Cookie

I am writing a small web scraper in C#. It is going to use HttpWebRequest to get the HTML file, find the required data, then report it back to the caller.

The required data is only available when a user is logged in. As I am new to interfacing programmatically with http, Javascript, et al, I am not going to try and log on programmatically. The user will have to log on to the website, and my program will get the stored cookie, and load it into the CookieContainer for the http request.

I've done enough research to know that the data belongs in the CookieContainer (I think), but I can't seem to find anywhere an example of how to find a cookie created by IE (or firefox, or chrome, etc), load it programmatically, populate the CookieContainer, and send it with an http get request. So how does one do all that?

Thanks!

Upvotes: 0

Views: 1747

Answers (1)

Viktor S.
Viktor S.

Reputation: 12815

I'm afraid you can't do that. Main reason is security. Because of cookies being used to identify a user, browser can't provide an easy access to cookies. Otherwise it would be really easy to still them.

You should better learn how to login user with HttpWebRequest or any other class like that.

Upvotes: 2

Related Questions