这是一长城宽带的认证页面,每当20分钟没有数据传输后,就会自动断掉网络连接,要想重新上网,就得进入认证页面,输入用户名和密码,然后单击“认证”(这里是一张图片,方法为POST),通过后才能继续上网。
这是认证页面的关键代码:
<table width="100%" border="0" cellpadding="4" cellspacing="0" bgcolor="#999999">
<form name=authenticateForm action=http://211.162.130.24:9091/user/home?textfield2=&textfield=&image.y=17&image.x=10&t=dag191op method=post>
<tr>
<td width="94" align="center" valign="middle"><img src="new_images/rrrr.jpg" width="80" height="19"></td>
<td width="296" valign="middle"><span class="p1"><font color="#FFFFFF"><font color="#000000">帐
号:</font></font></span> <input name="username" type="text" class="qqqqqqqq" size="10">
<span class="p1"><font color="#FFFFFF"> <font color="#000000">密
码:</font></font></span><font color="#FFFFFF">
<input name="password" type="password" class="qqqqqqqq" size="10">
</font></td>
<td width="61" valign="middle"><font color="#FFFFFF"><input name="image4" type="image" onclick=return src="images/dl.jpg" width="41" height="15" loginin(this);> <span class="p1"></span></font></td>
</form>
</table>
我想写个程序,当网络连接被断开后,自动发送用户名和密码通过认证,请高手给个思路,有源码更好,分不够可以再开新贴给,绝不食言!
这是认证页面的关键代码:
<table width="100%" border="0" cellpadding="4" cellspacing="0" bgcolor="#999999">
<form name=authenticateForm action=http://211.162.130.24:9091/user/home?textfield2=&textfield=&image.y=17&image.x=10&t=dag191op method=post>
<tr>
<td width="94" align="center" valign="middle"><img src="new_images/rrrr.jpg" width="80" height="19"></td>
<td width="296" valign="middle"><span class="p1"><font color="#FFFFFF"><font color="#000000">帐
号:</font></font></span> <input name="username" type="text" class="qqqqqqqq" size="10">
<span class="p1"><font color="#FFFFFF"> <font color="#000000">密
码:</font></font></span><font color="#FFFFFF">
<input name="password" type="password" class="qqqqqqqq" size="10">
</font></td>
<td width="61" valign="middle"><font color="#FFFFFF"><input name="image4" type="image" onclick=return src="images/dl.jpg" width="41" height="15" loginin(this);> <span class="p1"></span></font></td>
</form>
</table>
我想写个程序,当网络连接被断开后,自动发送用户名和密码通过认证,请高手给个思路,有源码更好,分不够可以再开新贴给,绝不食言!
解决方案 »
- 个人求职,寻Delphi的非MIS方面的开发工作。
- 16进制的byte存放
- 急急急!怎么比较一个字符串中包含了另一个字符串,并能知道是第几位开始有这个字符串的?
- 我想用postmessage关闭某个窗口,代码怎么写呀?
- 请问,哪有免费主页空间申请?
- 如何改变DBGRID那讨厌的拖动条的不规则的情况。
- Webbrowser 中设置referer统计系统无法正常统计到!
- cxGrid 过滤筛选如何操作筛选后的数据集!
- 布丁兄,在那个地址里没找到d6的下载,可知道那里有d6 的中文帮助么?
- ADOTABLE怎么搜索一记录?
- 关于日期时间控件DateTimePicker使用的问题
- 如何读取注册表信息和拷贝文件?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
2 Comment(s) to this tip [Write new comment]
[ Print tip ] Tip Rating (14):
{ To test this code put a TWebBrowser and A TButton component on the form }
function FillForm(WebBrowser: TWebBrowser; FieldName: string; Value: string): Boolean;
var
i, j: Integer;
FormItem: Variant;
begin
Result := False;
//no form on document
if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then
begin
Exit;
end;
//count forms on document
for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do
begin
FormItem := WebBrowser.OleObject.Document.forms.Item(I);
for j := 0 to FormItem.Length - 1 do
begin
try
//when the fieldname is found, try to fill out
if FormItem.Item(j).Name = FieldName then
begin
FormItem.Item(j).Value := Value;
Result := True;
end;
except
Exit;
end;
end;
end;
end;
//When the document is complete try to fill out the field homepage with the url
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
if FillForm(WebBrowser1, 'homepage', 'http://www.swissdelphicenter.ch') = False then
ShowMessage('Error. Field not available or no Form found.');
end; // Show the Webbrowser-Progress in Label1
procedure TForm1.WebBrowser1ProgressChange(Sender: TObject; Progress, ProgressMax: Integer);
begin
if ProgressMax = 0 then
begin
label1.Caption := '';
Exit;
end;
try
if (Progress <> -1) and (Progress <= ProgressMax) then
label1.Caption := IntToStr((Progress * 100) div ProgressMax) + '% loaded...'
else
label1.Caption := '';
except
on EDivByZero do Exit;
end;
end;
//For example you can load the page /en/addtip.php to the TWebBrowser
//When the document is Complete the form where you can put your homepage
//address is filled out
procedure TForm1.Button1Click(Sender: TObject);
begin
Webbrowser1.Navigate('http://www.swissdelphicenter.ch/en/addtip.php');
// Show the Titel of the currently active Webpage in the titlebar
// Den Titel der aktuellen Webseite in der Titeleiste anzeigen
Caption := Webbrowser1.OleObject.Document.Title;
end;
var
postList: TStrings;
begin
EditURL.Text := 'http://211.162.130.24:9091/user/home?t=dwg2zn63'; postList := TStringList.Create;
try
postList.Add('username=yourName');
postList.Add('password=yourPassword');
IdHTTP.Post( EditURL.Text, postList );
finally
EditURL.Text := IdHTTP.Response.Server + ': ' + IdHTTP.Response.ResponseText;
postList.Free;
end;
end;(注:用TIdHTTP控件、试试这样能叫通吗?)
var
postList: TStrings;
begin
EditURL.Text := 'http://community.csdn.net/expert/forum.asp'; postList := TStringList.Create;
try
postList.Add('login_name=cronuz');
postList.Add('password=myPassword');
IdHTTP.Post( EditURL.Text, postList );
finally
EditURL.Text := IdHTTP.Response.Server + ': ' + IdHTTP.Response.ResponseText;
postList.Free;
end;
end;(注:此為在CSDN上的TEST、楼主只要改成自己在CSDN上的用户名和密码、
就可叫通CSDN、返回:Microsoft-IIS/6.0: HTTP/1.1 200 OK)