所以我一直在尝试创建一个可以登录到特定网站的C#应用程序,但是如果没有通过韩国代理完成登录,那么这个网站将拒绝登录。
我不介意它是webrequest还是webbrowser,但我对WebBrowser控件稍微熟悉。
public static void remoteAuth() {
string usr = Properties.Settings.Default.username;
string pass = Properties.Settings.Default.password;
currentUri = new Uri(@"https://logins.daum.net/accounts/loginform.do?url=http%3A%2F%2Fblack.game.daum.net%2Fblack%2Findex.daum");
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create("https://logins.daum.net/accounts/loginform.do?url=http%3A%2F%2Fblack.game.daum.net%2Fblack%2Findex.daum");
WebProxy myProxy = new WebProxy("IP:PORT");
myRequest.Proxy = myProxy;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
webBrowser.DocumentStream = myResponse.GetResponseStream();
webBrowser.Navigating += new WebBrowserNavigatingEventHandler(webBrowser_Navigating);
remoteAuth();
}
private static void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
if (e.Url.AbsolutePath != "blank") {
currentUri = new Uri(currentUri, e.Url.AbsolutePath);
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(currentUri);
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
webBrowser.DocumentStream = myResponse.GetResponseStream();
e.Cancel = true;
}
}
这是我之前尝试过的,我用“IP:PORT”替换代理作为占位符。
我的代码目前有点乱,但我觉得分享一些东西好像更好,而不仅仅是提交一个空白的问题。
提前致谢!