开发者

How to log into a website using webbrowser control and username & password stored in variables

I want to be able to log into a website via C# webbrowser without any user input. I want to get the username and password from local variables.

I hope someone can help me.

Please give 开发者_如何学运维clear C# code examples.


Go to the login-page of the site, expose the <form></form> that does the login, mimic the form with a POST request and encode the username/password in the body of the POST.

To fabricate this, you'll probably have to make a custom request. Linking up the session ID of the Request & the web-browser will probably be tricky, you'd have to set the referral url manually in the next post, and migrate the cookies the server told you to set.


The other solution is to inject some javascript into the login page that populates the fields and hits the submit button.

Either way it's pretty page-specific.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜