Home > Back-end >  Consult about Delphi call baidu
Consult about Delphi call baidu

Time:10-03

My demand is this:
A, Delphi call baidu search,
2, return to search results (all ten, twenty, or, as long as you help me achieve)
Be very grateful!

CodePudding user response:

Use WebBrowser, such as:
 procedure TForm1. FormCreate (Sender: TObject); 
The begin
WebBrowser1. Navigate (' www.baidu.com ');
end;

CodePudding user response:

The building Lord should be called to perform the search baidu, simulate click is?

A few days ago saw BDMH webmaster blog said, hope is useful to the building Lord,


 
Procedure TForm1. Button1Click (Sender: TObject);
Var
I: Integer;
The Document: IHTMLDocument2;
Element: IHTMLElement;
Anchors: IHTMLElementCollection;
SLink: string;
The begin
//find netease news page links
SLink:='http://news.163.com/';
The Document:=Webbrowser1. Document as IHTMLDocument2;
If Assigned (Document) then
The begin
Anchors:=Document. Get_links;
//to iterate through all links
For I:=0 to Anchors. Do length - 1
The begin
Element:=Anchors. The item (I, varempty) as IHTMLElement;
//find specify links
If Assigned (Element) and (UpperCase ((Element as IHTMLAnchorElement). Href=UpperCase (sLink)) then
The begin
//execution click
Element. Click;
Break;
end;
end;
end;
end;


, of course, this is a click on the code, you need to perform to write text input box, you have a good supplement.
 if Succeeded (Dispatch. QueryInterface (IHTMLInputElement HTMLInputElement)) then 
The begin
With HTMLInputElement do//single-line text
The begin
If UpperCase (Type_='TEXT' then//judge the input box type;
The begin
If the trim (basedata. SysInfo. StrWebadvKeyWord) & lt;> "' then
The begin
If (Name=copy (trim (basedata. SysInfo. StrWebadvKeyWord), 1, pos (', ', the trim (basedata. SysInfo. StrWebadvKeyWord)) - 1))
Or (Name=copy (trim (basedata. SysInfo. StrWebadvKeyWord), pos (', ', the trim (basedata. SysInfo. StrWebadvKeyWord)) + 1)) then
The begin
Value:=strkeyword;
exit;
end;
end;
end;
end;
End

CodePudding user response:

The first requirement is not difficult, the second requirement, don't know what kind of results to return? Pure link or baidu search shows the result of the way?

CodePudding user response:

100 is too small

CodePudding user response:

Thank you to share learning

CodePudding user response:

More and more water Delphi plates, are these things all day,,,

CodePudding user response:

WebBrowser1. Navigate (' www.baidu.com ');

WebBrowser1. OleObject. Document
Will JS, first go to the HTML page each element can obtain, can operate, is very simple
  • Related