本来要登陆之后,点击下载的地址才行。如果我想用程序写出来的话,应该如何做???
解决方案 »
- WIN7+D2010编译的窗口总在最前在XP系统中失效的问题
- 请教一下c写的dll中,变量类型转换的问题。在线等,谢谢!
- DELPHI登陆窗体怎么制作啊~!!连接数据库
- delphi操作excel的问题,请帮忙
- 我用delphi調用計算器,但我怎樣在程序中取得該結果呢。
- 哪位大侠有泄漏的windows源码?能否提供一份?愿意出钱购买。若有,请留下您的邮件地址,万分感谢!还有,我在深圳!
- Form1.Canvas.Brush.Color:=$00000000+i*$100;
- 菜鸟问题:如何实现在数据库表中删除一条记录?
- 我想实现窗体的背景图!有些问题,请帮帮忙!
- 出现"Statement expected,but expression of type'TfrxCustomPreview'found",就如何解决?
- 怎样移位?
- DBGridEh同clientdataset排序成功了,但是过滤没有成功,呼唤高手!
1, 自动填写用户名密码,登陆automatic fill out HTML forms with TWebBrowser?
{ 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
list all links of a page of a TWebbrowser? procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
for i := 0 to Webbrowser1.OleObject.Document.links.Length - 1 do
Listbox1.Items.Add(Webbrowser1.OleObject.Document.Links.Item(i));
end;
{*****************}{ if there are frames }procedure TForm1.Button2Click(Sender: TObject);
var
u : variant;
v : IDispatch;
s : string; procedure RecurseLinks(htmlDoc: variant);
var
BodyElement : variant;
ElementCo: variant;
HTMLFrames: variant;
HTMLWnd : variant;
j, i : integer;
begin
if VarIsEmpty(htmlDoc) then
exit;
BodyElement := htmlDoc.body;
if BodyElement.tagName = 'BODY' then
begin
ElementCo := htmlDoc.links;
j := ElementCo.Length - 1;
for i := 0 to j do
begin
u := ElementCo.item(i);
s := u.href;
listLinks.Items.Add(s);
end;
end;
HTMLFrames := htmlDoc.Frames;
j := HTMLFrames.length - 1;
for i := 0 to j do
begin
HTMLWnd := HTMLFrames.Item(i);
RecurseLinks(HTMLWnd.Document);
end;
end; // RecurseLinks
begin
v := WebBrowser1.document;
listLinks.Clear;
RecurseLinks(v);
end;