我正在尝试构建一个服务来登录网上银行网站并下载用户的最新交易信息。
我正在用 .NET/C# 构建它,我正在尝试按照我在另一篇文章中看到的关于如何执行此操作的示例... .NET HTTP POST 方法 - Cookies 问题
但我似乎无法让这个例子起作用。
我要登录的网站是... http://www.communityamericacu.com/
这是我到目前为止想出的...
public void RetrieveTransactions()
{
var request = (HttpWebRequest) WebRequest.Create("https://secureaccess.cacu.com/accountlink/SignOn/SignOn.aspx");
var cookies = new CookieContainer();
request.CookieContainer = cookies;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
using (var requestStream = request.GetRequestStream())
{
using (var writer = new StreamWriter(requestStream))
{
writer.Write("user=****&PIN=****&BankFolder=Banking&BrandID=1&BrandFolder=cacu&BrandType=R&screenwidth=&screenheight=&RemoteLogin=N&ExitURL=&UserJavaPlatForm=Win32&UserJavaBrowser=Netscape&UserJavaVersion=5.0+%28Windows+NT+6.1%3B+WOW64%29+AppleWebKit%2F536.11+%28KHTML%2C+like+Gecko%29+Chrome%2F20.0.1132.47+Safari%2F536.11&UserJavaCodeName=Mozilla&UserJavaColorDepth=32&UserJavaColors=4294967296&UserJavaCurrentResolution=1600x900&UserJavaMaxResolution=1600x870&UserJavaEnabled=Yes&UserJavaAAFonts=No&UserJavaPlugins=+Remoting+Viewer+Native+Client+Chrome+PDF+Viewer+Shockwave+Flash+Shockwave+Flash+Adobe+Acrobat+Microsoft+Lync+2010+Meeting+Join+Plug-in+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+Microsoft+Office+2010+Microsoft+Office+2010+Google+Update+NVIDIA+3D+Vision+NVIDIA+3D+VISION+Java%28TM%29+Platform+SE+7+U5+Java+Deployment+Toolkit+7.0.50.255+Shockwave+for+Director+Silverlight+Plug-In+Remoting+Viewer+Native+Client+Chrome+PDF+Viewer+Shockwave+Flash+Shockwave+Flash+Adobe+Acrobat+Microsoft+Lync+2010+Meeting+Join+Plug-in+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+QuickTime+Plug-in+7.7.2+Microsoft+Office+2010+Microsoft+Office+2010+Google+Update+NVIDIA+3D+Vision+NVIDIA+3D+VISION+Java%28TM%29+Platform+SE+7+U5+Java+Deployment+Toolkit+7.0.50.255+Shockwave+for+Director+Silverlight+Plug-In&UserJavaUTCOffset=5");
}
}
using (var responseStream = request.GetResponse().GetResponseStream())
{
if (responseStream != null)
{
using (var reader = new StreamReader(responseStream))
{
var result = reader.ReadToEnd();
}
}
}
}
但这是我得到的回应......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>@ccountLink Error</title>
</head>
<body>
An error occurred.
</body>
</html>
当我尝试登录该站点时,即使用户名和密码不正确,这也不是我得到的。
在这一点上,这一切都让我有点过头了。我能得到的任何帮助将不胜感激。