Evo koda:
Pocni google search:
Code:
[Button1.click]
if scombobox1.ItemIndex=0 then
begin
GetSitesGoogleApi;
sgauge1.Progress:=0;
sbutton2.Enabled:=false;
sbutton3.SetFocus;
timer1.Enabled:=true;
scombobox3.Enabled:=false;
scombobox1.Enabled:=false;
scombobox5.Enabled:=false;
scombobox2.Enabled:=false;
sedit1.Enabled:=false;
end;
Code:
procedure TForm1.GetSitesGoogleApi;
var criter:string;
begin
google:=TStringList.Create;
criter:= ChangeString(sedit1.Text,'%20'); /// ne znam sto ali google Api izbacuje gresku ako ne stavim enkodiran url..
With HttpCli1 do begin
URL := 'http://ajax.googleapis.com/aja...es/search/web?v=1.0&start=' + slabelfx4.Caption + '&rsz=large&q=' + criter;
RequestVer := '1.1';
Agent := trim(scombobox2.Text);
RcvdStream := TMemoryStream.Create;
try
Get;
except
ShowMessage('There has been an error , check your internet connection !');
RcvdStream.Free;
Exit;
end;
RcvdStream.Seek(0,0);
google.LoadFromStream(RcvdStream);
slabelfx4.Caption:=inttostr(strtoint(slabelfx4.Caption) + 8);
RcvdStream.Free;
end;
end;
Code:
procedure TForm1.ParseGoogleApi;
var Pos: integer;
sText: string;
begin
sText := ExtractText(google.Text, '"url":"', '","visibleUrl"', 1, Pos);
while sText <> '' do
begin
schecklistbox1.Items.Add(sText);
sText := ExtractText(google.Text, '"url":"', '","visibleUrl"', Pos, Pos);
end;
slabelfx5.Caption:=inttostr(schecklistbox1.Items.Count);
end;
Code:
[Timer1]
if length(google.Text)>40 then
begin
ParseGoogleApi;
slabelfx5.Caption:=inttostr(schecklistbox1.Items.Count);
google.clear;
slabelfx13.Caption:='Working';
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%3F','?', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%3D','=', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%26','&', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%3A',':', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%3B',';', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%40','@', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%3B','+', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%25','%', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%5B','[', [rfReplaceAll]);
schecklistbox1.Items.Text := StringReplace(schecklistbox1.Items.Text,'%5D',']', [rfReplaceAll]);
sgauge1.AddProgress(100 div 8);
GetSitesGoogleApi;
end
end;
To mi je kod koji skida stranice sa google search-a , isti je princip i za skidanje stranica iz liste i parsovanja...