Google parser for a few minutes in Delphi7

by SeoCoder on Апрель 18, 2007

For our task, we need small learning programming at Delphi, free components from the set of «Embedded Web Browser». At the start, we need a certified Delphi7, and the connection to the Internet to verify the program. Download and install component from http://bsalsa.com/DP/download.php?file=0.
Steps install :
1.After download, unzip to a folder «.. : \ Borland \ Delphi7 \ lib»

2. In Delphi, select File-> Open
d1.gif
Go to the directory («..: \ Borland \ Delphi7 \ lib \ EmbeddedWB_D 2005 \ Source «).
3. Choose file EmbeddedWebBrowser_D7.dpk «and click Open.
d2.gif
4. Click compile and install
5. All component has been installed. If all goes well, proceed to write the program itself as a preparatory phase completed.
Of these components to our task, we need only one – TextIEParser. Create a form in Delphi. Placing to form panel, edit, speedbutton. Statusbar and memo-setting property

Align = alClient

.
Do not forget about our IEParser.
d3.gif
Changing property caption of the form. There has been a listing of our forms :

main unit;
unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls;

type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Panel1: TPanel;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
Memo1: TMemo;
IEParser1: TIEParser;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

end.

To begin methodically add functional. Adding to the OnClick event of our SpeedButton. They are simply double click on the button on the form.

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
	IEParser1.URL:='http://www.google.com/ie?q='+Edit1.Text+'&num=100&hl=en&lr=&newwindow=1&c2coff=1';
	IEParser1.Go;
end;

This simple code in the task of us happy, it gives only 100 results. Large potential look at the following examples, if this would be helpful people. Our task now ring code references received and put it in the Memo. Discovering our beloved browser such a request http://www.google.com/ie?q=inurl:bbs.cgi&num=100&hl=en&lr=&newwindow=1&c2coff=1 I jogging show fetched pages.
Looking code html pages come to the conclusion that what we need is, tags A. And that the references that are not in google, and we need them. We want our event IEParser – onAnchor procedure

procedure TForm1.IEParser1Anchor(Sender: TObject; hRef, Target, Rel, Rev,
Urn, Methods, Name, Host, HostName, PathName, Port, Protocol, Search,
Hash, AccessKey, ProtocolLong, MimeType, NameProp: String;
Element: TElementInfo);
begin
if Pos('google', href) = 0 then Memo1.Lines.Add(href);
StatusBar1.SimpleText:='Find links: '+IntToStr(Memo1.Lines.Count+1);
end;

d4.gif
All our simple parser ready!