开发者

How can I download content from a webpage that requires login information

开发者 https://www.devze.com 2023-02-04 18:21 出处:网络
I am trying to create a small application that will do开发者_高级运维wnload the content of a certain webpage. I am able to do that with certain web pages using WebRequest. However the web page I need

I am trying to create a small application that will do开发者_高级运维wnload the content of a certain webpage. I am able to do that with certain web pages using WebRequest. However the web page I need to download from requires login information.

I am using C# and Visual Studio Express 2010

Thank you in advance...


Have a look at HttpWebRequest.Credentials.


You can either simply use HttpWebRequest.Credentials as CesarGon mentioned or if it's HTTP Basic authorization, add an appropriate HTTP header (that would be environment independent):

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

where dXNlcm5hbWU6cGFzc3dvcmQ= is base 64 encoded username:password.

0

精彩评论

暂无评论...
验证码 换一张
取 消