Google PageRank components for Delphi (GPRD) - v1.5.0 (Freeware!)
Introduction
Yes! Now Delphi developers can embed Google PageRank
retrieving functionality into own applications. This components allows you
to easily retrieve Google's PageRank value and also show it
by manner similar to Google Toolbar.
Download Free Version Now!
Order full sources Now!
Requirements- Borland Delphi 5,6,7,2005(Win32),2006(Win32).
Installation
 |
- Unzip the PRFREE.ZIP file with preserving folders structure.
- Start Delphi IDE and open package file ("Delphi ?\pagerank_d?.dpk", where "?"
your Delphi version).
- Click on "Compile" and then on "Install" buttons. Delphi should report you
that two new components has been installed: TPageRank and TPageRankControl.
- This components you can find on the "Internet" page of components palette.
|
Overview
The module named PageRank(pagerank.pas) contain two classes
and two function. You can use non-visual component TPageRank to
retrieve the PR value and the TPageRankControl to show this
value. Also you can use GetURLQuery function to make PageRank value
retrieving query and the StrToPageRank function to convert receiving
document to PR value.
TPageRank
TPageRank component declaration:
type
TOnGetRank = function (const Page: string; var Rank: string): Boolean of object;
TPageRank = class(TComponent)
public
property Control: TControl read FControl write FControl;
procedure UpdatePageRank;
function IsExecuted: Boolean;
published
property Rank: Integer read GetFRank;
property Page: string read FPage write SetFPage;
property Auto: Boolean read FAuto write FAuto;
property NonBlock: Boolean read FNonBlock write FNonBlock;
property OnGetRank: TOnGetRank read FOnGetRank write FOnGetRank;
end;
Properties and methods description:
- public
- property Control: TControl;
- — link to visual component, that should refresh when
the Pagerank value is changed. The Invalidate method of this
component is called when Pagerank value is changed.
- procedure UpdatePageRank;
- — call this method to update Pagerank value manually.
- function IsExecuted: Boolean;
- — indicate that the Pagerank value retrieving process
in progress.
- published
- property Rank: Integer;
- — Pagerank value. Note, that actual pagerank value is
contained only in low byte, i.e. you should make Rank and 255 to
get real Pagerank value.
- property Page: string;
- — URL to page whose pagerank value want to retrieve.
- property Auto: Boolean;
- — auto-retrieve pagerank value - the UpdatePageRank
method called is currently Rank value is empty.
- property NonBlock: Boolean;
- — execute pagerank retrieving process in separate thread.
- property OldVersion: Boolean;
- — Use old Google Toolbar (prior to 2.0.114) queries algorithm.
- property OnGetRank: TOnGetRank;
- — this event occur when need send request to Google
servers. The input parameter Pagecontain the URL for this request.
The event handler should return received document in Rank parameter
and result TRUE when success or FALSE when fail. See below
for sample of implementation of this event handler.
Although GPRD intended to work with internet, it's not contain any networking
code. Such decision is selected because of every developer has own solutions
and use different methods for access to net. All networking code should be
provided by developer as handler of OnGetRank event.
The simplest example of implementation of OnGetRank event handler
provided in the code below. In the demo project, shipped with components you
can see another implementation of this event handler.
uses
ActiveX, URLMon;
function TForm1.OnGetRank(const URL: string; var Rank: string): Boolean;
var
I: Integer;
Stream: IStream;
begin
Result := FALSE;
if URLOpenBlockingStream(nil, PChar(URL), Stream, 0, nil) = S_OK then begin
SetLength(Rank, 32);
if Stream.Read(PChar(Rank), 32, @I) = S_OK then begin
SetLength(Rank, I);
Result := TRUE
end;
end;
end;
TPageRankControl
 |
TPageRankControl is visual component intended to show the pagerank
value as colored bar like one on the Google toolbar and as optional
text. The TPageRankControl declaration: |
type
TPageRankControl = class(TGraphicControl)
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property PageRank: TPageRank read FPageRank write SetFPageRank;
property BorderColor: TColor read FBorderColor write SetFBorderColor default clGray;
property FillerColor: TColor read FFillerColor write SetFFillerColor default clGreen;
property FilledColor: TColor read FFilledColor write SetFFilledColor default clWhite;
property ShowText: Boolean read FShowText write SetFShowText default TRUE;
property BarWidth: Integer read FBarWidth write SetFBarWidth default 7;
property Align;
property Anchors;
property Color;
property Font;
property Hint;
property ParentColor;
property ParentFont;
property ParentShowHint;
property ShowHint;
property PopupMenu;
property Visible;
property OnClick;
property OnDblClick;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnContextPopup;
end;
- published
- property PageRank: TPageRank;
- — TPageRank control used to get the PR value.
- property BorderColor: TColor;
- — color of pagerank bar border.
- property FillerColor: TColor;
- — color of empty part of pagerank bar.
- property FilledColor: TColor;
- — color of empty part of pagerank bar.
- property ShowText: Boolean;
- — show text with pagerank value above pagerank bar.
- property BarWidth: Integer;
- — thickness of pagerank bar in pixels.
Other properties is simply inherited from TControl and moved to published
section for more conveniences.
Functions
If you don't want to use any components, you can use those two functions
to retrieve pagerank value. The first function, GetURLQuery make
query string for specified page. For example, for http://www.irnis.net/
it will return http://toolbarqueries.google.com/search?client=navclient-auto&ch=62887370433&ie=UTF-8&features=Rank&q=info:http://www.irnis.net/.
The next, StrToPageRank help to extract the pagerank value from recieved
content.
function GetURLQuery(const URL: string): string;
function StrToPageRank(const S: string): Integer;
The simple example of using those function for retrieveng pagerank value:
uses
ActiveX, URLMon;
function GetRank(const URL: string): Integer;
var
S: string;
I: Integer;
Stream: IStream;
begin
Result := -1;
S := GetURLQuery(URL);
if URLOpenBlockingStream(nil, PChar(S), Stream, 0, nil) = S_OK then begin
SetLength(S, 32);
if Stream.Read(PChar(S), 32, @I) = S_OK then begin
SetLength(S, I);
Result := StrToPageRank(S) and 255
end;
end;
end;
Changes history
16.06.2006 | GPRD v1.5.0 released. |
|
- Added DCUs for Delphi 2006.
|
16.02.2006 | GPRD v1.4.0 released. |
|
- Fixed memory leak bug in freeware version.
|
27.04.2004 | GPRD v1.3.0 released. |
|
- Added DCUs for Delphi 2005.
|
13.12.2004 | GPRD v1.2.0 released. |
|
- Added DCUs for Delphi 6.
|
10.11.2004 | GPRD v1.1.0 released. |
|
- Added package files (*.dpk).
- Added OldVersion property for TPageRank component.
|
28.10.2004 | GPRD v1.0.0 released. |
| First public release |
Licenses
All copyrights to Google PageRank for Delphi are exclusively owned by
the author - Irnis Haliullin.
More details see in License.txt, shipped with components.
Contact
If you have any questions or suggestions about Google PageRank for Delphi,
please contact by mail to irnis@irnis.net.
|