0

I want to use the WebRequest class to post data to a website. This works fine, however the website I'm posting to requires cookies/sessions (it's a login form). After logging in I need to retrieve some account information (this is information on a specific page).

How can I make sure the login information is being stored? In AutoIT I did this using a hidden webbrowser, however I want to use a console application for it.

My current code (to login) is too long to post here, so it can be found here.

Bart
  • 19,692
  • 7
  • 68
  • 77
Devator
  • 3,686
  • 4
  • 33
  • 52
  • What do you mean by "making sure the login information is being stored"? Is there information on the page you need to scrape, are you looking for information within cookies? – cgatian Apr 21 '12 at 15:24

2 Answers2

0

You need to store the cookie that you get after logging in and then send that cookie when you request pages containing personal information.

Here is an example of using cookies with WebRequest

It is possible that you can't connect because the session has ended so in this case you need to relogin.

Community
  • 1
  • 1
Dorin
  • 2,482
  • 2
  • 22
  • 38
0

Take a look at my aspx sessions scraper on bitbucket. It does exactly what you are asking for, including some aspx webforms specific extensions, like sending postbacks etc.

m0sa
  • 10,712
  • 4
  • 44
  • 91
  • Hello Sir, is it possible to have a proper working sample, actually the problem is i am trying to scrape a website using login credentials, but what i am receiving in response is the page i requested, instead of the page displayed after successful login. i simply have a Login ID and Password and Login button on my aspx page. waiting for reply. – Gunwant Saini Apr 25 '12 at 10:18