How do you login to a webpage and retrieve its content in C#?

前端 未结 7 2034
孤街浪徒
孤街浪徒 2020-12-30 17:13

How do you login to a webpage and retrieve its content in C#?

7条回答
  •  清酒与你
    2020-12-30 17:37

    That depends on what's required to log in. You could use a webclient to send the login credentials to the server's login page (via whatever method is required, GET or POST), but that wouldn't persist a cookie. There is a way to get a webclient to handle cookies, so you could just POST the login info to the server, then request the page you want with the same webclient, then do whatever you want with the page.

提交回复
热议问题