2011-06-21 163 views
0

我比较新使用c#。现在我正在做一个关于自动登录网络的应用程序并收集数据!我已经搜索了一些关于这方面的信息,并且我知道首先我必须将我的帐户和密码发布到网站上。例如:c#网站登录到网站

WebRequest req = WebRequest.Create(formUrl); 
req.ContentType = "application/x-www-form-urlencoded"; 
req.Method = "POST"; 
byte[] bytes = Encoding.ASCII.GetBytes(formParams); 
req.ContentLength = bytes.Length; 
using (Stream os = req.GetRequestStream()) 
{ 
    os.Write(bytes, 0, bytes.Length); 
}         

formUrl是我必须张贴的acount和密码信息的网址和formParams是acount和密码的信息。现在的问题是:如何获得formUrl。

下面是我的一些webside的html代码:

<form name="form1" method="post" action="/cn/LogForm.aspx" onsubmit="return CheckLogin(this);"> 
<input type="hidden" name="backurl" value="/cn/assistant.aspx"/> 
<table width="262" border="0" align="center" cellpadding="0" cellspacing="0"> 
    <tr> 
     <td width="60" height="30" align="center">用户名:</td> 
     <td width="130"><input name="Username" type="text" class="border-login" tabindex=1 /></td>  " 

我想登录的webside是 “http://www.cantonfair.org.cn/cn/”

回答

3

使用FireBug, Firefox插件,通过在Firefox中打开页面来查找发布URL。