1
我想建立一个服务登录到在线银行网站并下载用户的最新交易信息。.NET HTTPS请求 - 发布数据登录到网站
我建立它在.NET/C#,我试图按照我看到的关于如何做到这一点另一篇文章的例子... .NET HTTP POST Method - Cookies issue
但我似乎无法让示例工作。
,我试图登录到是该网站... 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>
当我尝试登录到网站时,即使使用不正确的用户名和密码,这也不是我得到的结果。
在这一点上,这些东西都比我头脑清醒。任何帮助,我可以得到将不胜感激。
这听起来很腥。由于ViewState验证可能无法实现。 – jrummell 2012-07-06 15:18:25