5,388
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
Document: IHTMLDocument2;
Element: IHTMLElement;
Anchors: IHTMLElementCollection;
sLink: string;
begin
//查找网易新闻页面链接
sLink := 'http://news.163.com/';
Document := Webbrowser1.Document as IHTMLDocument2;
if Assigned(Document) then
begin
Anchors := Document.Get_links;
//遍历所有链接
for i := 0 to Anchors.length - 1 do
begin
Element := Anchors.item(i, varempty) as IHTMLElement;
//找到指定链接
if Assigned(Element) and (UpperCase((Element as IHTMLAnchorElement).href) = UpperCase(sLink)) then
begin
//执行点击
Element.Click;
Break;
end;
end;
end;
end;
if Succeeded(Dispatch.QueryInterface(IHTMLInputElement,HTMLInputElement)) then
begin
With HTMLInputElement do//单行文本
begin
if UpperCase(Type_)='TEXT' then//判断输入框类型;
begin
if trim(basedata.SysInfo.strWebadvKeyWord)<>'' then
begin
if (Name=copy(trim(basedata.SysInfo.strWebadvKeyWord),1,pos(',',trim(basedata.SysInfo.strWebadvKeyWord))-1))
or(Name=copy(trim(basedata.SysInfo.strWebadvKeyWord),pos(',',trim(basedata.SysInfo.strWebadvKeyWord))+1)) then
begin
Value:=strkeyword;
exit;
end;
end;
end;
end;
end
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('www.baidu.com');
end;