c#网站登录网站

时间:2011-06-21 08:37:35

标签: c# web

我使用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是我必须将帐号和密码信息发布到的URL,而formParams是帐号和密码的信息。现在的问题是:如何获取formUrl。

以下是我的一些网络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>        "

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

2 个答案:

答案 0 :(得分:3)

通过在Firefox中打开页面,使用FireBug,Addon for firefox查找发布网址。

答案 1 :(得分:0)

这不仅仅是ACTION路径吗?或者我错过了什么?

action="/cn/LogForm.aspx"

formURL是http://www.cantonfair.org.cn/cn/LogForm.aspx